CN109388568B - Code testing method and device - Google Patents

Code testing method and device Download PDF

Info

Publication number
CN109388568B
CN109388568B CN201811147512.5A CN201811147512A CN109388568B CN 109388568 B CN109388568 B CN 109388568B CN 201811147512 A CN201811147512 A CN 201811147512A CN 109388568 B CN109388568 B CN 109388568B
Authority
CN
China
Prior art keywords
code
test case
function
identification information
original version
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.)
Active
Application number
CN201811147512.5A
Other languages
Chinese (zh)
Other versions
CN109388568A (en
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201811147512.5A priority Critical patent/CN109388568B/en
Publication of CN109388568A publication Critical patent/CN109388568A/en
Application granted granted Critical
Publication of CN109388568B publication Critical patent/CN109388568B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/3684Test management for test design, e.g. generating new test cases
    • 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/368Test management for test version control, e.g. updating test cases to a new software version

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 embodiment of the application discloses a code testing method and device. One embodiment of the method comprises: determining a target mark object in all mark objects; determining a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version; and testing the code of the updated version by using the test case of the code of the updated version. The method and the device realize that the marked object which can be tested only by predetermining the test case of the original version is only needed, automatically analyze the marked object which needs to be tested again when the code changes in the subsequent code test of any version of the updated version, determine the corresponding test case from the test case of the original version as the test case of the code of the updated version, and reduce the cost of the test process. The method can accurately determine the code branch of any level of which the code changes and needs to be tested again, and select the corresponding test case for accurate testing.

Description

Code testing method and device
Technical Field
The present application relates to the field of computers, and in particular, to a method and an apparatus for testing code.
Background
Before the code is on-line, the code needs to be tested by using a test case. At present, functions that can be tested by each test case are analyzed manually by using relevant information of functions output after the test cases test codes, and the test cases are adjusted according to an analysis result. However, the codes need to be updated continuously along with the expansion of the service, and each time a new version of codes is obtained by updating, the testing needs to be performed again, so that the cost of the testing process is huge.
Disclosure of Invention
The embodiment of the application provides a code testing method and device.
In a first aspect, an embodiment of the present application provides a code testing method, where the method includes: determining a target markup object of all the markup objects, wherein identification information of the markup object is generated based on at least part of the code of the markup object, and the identification information of the target markup object in the updated version of the code is different from the identification information of the target markup object in the original version of the code; determining a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version; and testing the code of the updated version by using the test case of the code of the updated version.
In a second aspect, an embodiment of the present application provides a code testing apparatus, including: an object determination unit configured to determine a target markup object of all markup objects, wherein identification information of the markup object is generated based on at least a part of a code of the markup object, and the identification information of the target markup object in an updated version of the code is different from the identification information of the target markup object in an original version of the code; the case determining unit is configured to determine a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version; and the code testing unit is configured to test the code of the updated version by using the test case of the code of the updated version.
According to the code testing method and device provided by the embodiment of the application, the target mark object in all mark objects is determined, wherein the identification information of the mark object is generated based on at least part of the code of the mark object, and the identification information of the target mark object in the updated version of the code is different from the identification information of the target mark object in the original version of the code; determining a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version; and testing the code of the updated version by using the test case of the code of the updated version. The method and the device realize that the marked object which can be tested only by predetermining the test case of the original version is only needed, automatically analyze the marked object which needs to be tested again when the code changes in the subsequent code test of any version of the updated version, determine the corresponding test case from the test case of the original version as the test case of the code of the updated version, and reduce the cost of the test process. The method can accurately determine the code branch of any level of which the code changes and needs to be tested again, and select the corresponding test case for accurate testing.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 shows a flow diagram of one embodiment of a code testing method according to the present application;
FIG. 2 is a diagram illustrating the effect of contrast of identification information in two versions of code;
FIG. 3 shows a schematic block diagram of one embodiment of a code testing apparatus according to the present application;
FIG. 4 is a block diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Referring to FIG. 1, a flow diagram of one embodiment of a code testing method according to the present application is shown. The method comprises the following steps:
step 101, determining a target mark object in all mark objects.
In this embodiment, neither the original version nor the updated version refers to a certain version. After a part of the code in one version is modified, the version can be used as an original version, the code of the version can be used as the code of the original version, and the modified code can be used as the code of an updated version. For example, the code of a project is updated from version 1 to version 5, the code of version 5 is obtained after the partial code of version 4 is modified, when the code of version 5 is tested, version 4 can be used as the original version, and version 5 can be used as the updated version.
In this embodiment, a plurality of markup objects are included in one version of code. The identification information of the tagged object is generated based on at least a portion of the code of the tagged object. When testing an updated version of code, a target markup object of all markup objects may be first determined, and identification information of the target markup object in the updated version of code is different from identification information of the target markup object in the original version of code.
For example, a mark object is a function, all parameters of the function may be combined to serve as identification information of the function, and the identification information of the function is added to both the original version of code and the updated version of code in advance. When the identification information of the function in the original version of code is different from the identification information of the function in the updated version of code, the function may be a target mark object.
In this embodiment, the identification information of each mark object in the original version of code may be recorded in advance. When testing the updated version of the code, the updated version of the code may be traversed, for example, through a syntax tree, to obtain the identification information of each markup object in the updated version of the code.
Taking all the identification objects as functions as an example, the identification information of each function in the code of the original version may be recorded in advance, and after traversing the code of the updated version, the identification information of each function in the code of the updated version may be obtained. The identification information of all functions in the original version of code may constitute the original set of identification information. The identification information of all functions in the updated version of code may constitute an updated set of identification information. When one identification information in the updated identification information set does not appear in the original identification information set, it may be determined that the identification information of the function to which the identification information belongs in the code of the original version is different from the identification information of the function to which the identification information belongs in the code of the updated version, and the function may be a target mark object.
In some optional implementations of this embodiment, marking the object includes: function, code branch in function. Code branches may include, but are not limited to: judging type code branch and loop type code branch. For example, if else statements of the judged type serve as a code branch, and the code in the if else statements is the code of the code branch. The for loop statement may be treated as a code branch, and the code in the for loop statement is the code of the code branch. A function can contain a plurality of code branches, and at least one code branch in the function is called from the calling starting time to the calling ending time of the function in the calling process of the function. Code branches may also have dependencies between them. In other words, one code branch may contain multiple other code branches. For example, an if else statement is used as a code branch, and the code branch also includes another if else statement used as a code branch and a for loop statement used as a code branch.
For a code branch as a mark object, when the code of the code branch in the original version of the code is changed, the code of the code branch in the original version of the code is different from the code of the code branch in the updated version of the code, and correspondingly, the identification information of the code branch in the original version of the code is different from the identification information of the code branch in the updated version of the code, so that the code branch can be determined as the target mark object.
Please refer to fig. 2, which shows a schematic diagram illustrating the comparison effect of the identification information in the two versions of the code.
The first statement of the function with the name of func2 is a Log statement, that is, a Log statement, and the content in the quotation mark in the Log statement is the identification information a43ef43c493edb3f of the function with the name of func 2. The function named func2 includes two for loop statements. Each for loop statement is a code branch, and each for loop statement is used as a mark object. From top to bottom, the 2 nd for loop statement is located in the 1 st for loop statement. The first sentence in the 2 nd for loop sentence is a Log sentence, the content in the quotation mark in the Log sentence is the identification information of the function with the name of func2 + the identification information of the 2 nd for loop sentence, and the identification information of the 2 nd for loop sentence is generated based on the code in the 2 nd for loop sentence. System.out.println statement is included in the code of the 2 nd for loop statement. System.out. println statement in 2 nd for loop statement in original version of code, content in quote of "". In the updated version of the code, the system.out in the 2 nd for loop statement is "#" in the quote of the println statement. Since the identification information of the 2 nd for loop statement is generated based on the code in the 2 nd for loop statement, the code of the 2 nd for loop statement in the code of the original version is different from the code of the 2 nd for loop statement in the code of the updated version, and therefore the identification information of the 2 nd for loop statement in the code of the original version is different from the identification information of the 2 nd for loop statement in the code of the updated version. The identification information of the 2 nd for loop statement in the original version of code is L909957905. The identification information of the 2 nd for loop statement in the code of the updated version is L709953848. By comparing the identification information of the code branches, it can be determined that the identification information of the 2 nd for loop statement in the code of the original version is different from the identification information of the 2 nd for loop statement in the code of the updated version, and it is determined that the 2 nd for loop statement is the target annotation object, in other words, it is determined that the code of the 2 nd for loop statement changes, when the code of the updated version is tested, the 2 nd for loop statement needs to be tested again, and correspondingly, the test case of the updated version selected from the test cases of the code of the original version needs to be able to test the 2 nd for loop statement. By comparing the identification information of the code branches, different code branches of the identification information in each level in the code of the original version and the code of the updated version can be accurately determined, that is, the code branch of the code of each level is accurately determined, and when the code of the updated version is tested, the code branch of the code which is changed can be tested if the test case of the updated version is selected from the test cases of the code of the original version.
In some optional implementation manners of this embodiment, for each function, a hash value may be calculated based on a return value type of the function, a function name of the function, a parameter of the function, a thrown exception type of the function, and the like in the code of the function, and the calculated hash value is used as identification information of the function. For example, information such as a return value type, a function name, a function parameter, and a thrown exception type of one function may be combined to obtain one piece of combined information, a hash value corresponding to the combined information may be calculated by using the MD5 algorithm, and the calculated hash value may be used as identification information of the function. After the identification information of the function is calculated, a log statement containing the identification information of the function may be written, and the log statement is added before a first statement in the code of the function, that is, the log statement is used as the first statement in the code of the function. Thus, when a function is called, a log statement is executed first, and identification information of the function in the log statement is printed in the log.
In some optional implementations of this embodiment, for a code branch, the second association information may be obtained based on a branch type of the code branch, a parameter in the code branch, a statement in the code branch, a layer depth of the code branch, and the like. For example, for a code branch, the branch type of the code branch, the parameter in the code branch, the statement in the code branch, the layer depth of the code branch, and the like may be combined to obtain the second related information, a hash value corresponding to the second related information may be calculated, and the calculated hash value may be used as the identification information of the code branch. For each code branch of each function, a log statement containing the identification information of the function and the identification information of the code branch can be written respectively, and the log statement is added before the first statement in the code of the code branch. Thus, when a code branch is called, a log statement is executed first, and identification information of a function in the log statement and identification information of the code branch are printed in the log.
And 102, determining a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version.
In this embodiment, the code of the original version may be tested in advance by using the test case of the code of each of the multiple test cases of the code of the original version, and the markup object invoked after the code of the original version is tested by using each test case may be determined.
When the mark object comprises a function and a code branch in the function, the function is called from the calling starting time to the calling ending of the function in the calling process, and at least one code branch in the function is called. When a function is called by testing the code of the original version by using the test case of the code of the original version, the corresponding relation between the test case of the code of the original version and the identification information of the function can be established, and meanwhile, at least one code branch in the function is called when the function is called, and the corresponding relation between the test case of the code of the original version and the at least one code branch can be established. The test case of the code of an original version can call the same function for multiple times in the test process, and at least one code branch is called in the process of calling the function each time. The code branches called in the process of calling the same function at different times can be the same or partially the same or completely different.
The identification information of the function called when the test case of the code of the original version is used to test the code of the original version may be referred to as identification information of the function corresponding to the code of the original version. The identification information of the code branch called when the test case of the code of the original version is used for testing the code of the original version can be referred to as the identification information of the code branch corresponding to the code of the original version. After the test case of each original version of the code is used to test the original version of the code, the test case of each original version of the code may correspond to the identification information of the plurality of functions, and the test case of each original version of the code may correspond to the identification information of the plurality of code branches.
In this embodiment, the test case of the code of the updated version may be determined based on the determined target mark object and the test case of the code of the original version.
Taking all the target mark objects as functions as an example, for a function as a target mark object, the function identification information in the code of the original version is different from the function identification information in the code of the updated version, and therefore, it is necessary to determine a corresponding test case to test the function again. Determining all test cases of the code of the updated version may be equivalent to determining test cases that may be tested again for all functions that are target mark objects. When determining the test cases of the code of the updated version, the test case with the most identification information as the function of the target mark object may be selected from all the test cases of the code of the original version. In other words, since the identification information of the function corresponding to the test case of the code of the original version is the identification information of the function called when the test case of the code of the original version is used to test the code of the original version, selecting the test case with the largest identification information of the corresponding function from the test cases of the code of all the original versions is equivalent to selecting the test case with the largest number of functions that can be tested and are taken as the target mark object from the test cases of the code of all the original versions. Then, for the remaining functions as the target mark objects, the test cases which can test the most functions in the remaining functions as the target mark objects are selected from the test cases of the remaining original versions of the code. And in the same way, for the functions which are remained after the last selection and are used as the target mark objects, the test cases which can test the functions which are remained and are used as the target mark objects and have the maximum number are selected from the test cases of the remained codes of the original version. Until there are no remaining functions as target mark objects or no alternative original versions of test cases.
In some optional implementations of this embodiment, a log statement may be added before the first statement of each markup object in the original version of code. The log statement includes: identification information of the tagged object. The original version of code may be tested using a plurality of test cases. For each test case of the code of the original version, determining a label object called after the test case of the code of the original version tests the code of the original version based on the identification information output to the log after the test case of the code of the original version tests the code of the original version. For a code branch, in addition to the identification information of the code branch, the log statement of the first statement of the code branch may also include the identification information of the function to which the code branch belongs. In the process of testing by using the test case of the code of the original version, when the function is called, the log statement which is the first statement of the function is executed, and the identification information of the function can be output to the log. When the code branch is called, the identification information of the code branch may then be output to the log. The function and the code branch that are called after the code of the original version is tested by using the test case of the code of each original version can be respectively determined according to the identification information of the function and the identification information of the code branch that are output to the log after the code of the original version is tested by using the test case of the code of each original version. The jump path information of each mark object when the test case of the code of the original version is used for testing the code of the original version can be further determined for each test case of the code of the original version.
The jump path information of a function may be identification information of the function. The jump path information for a code branch indicates all called code branches and call orders between the time the function to which the code branch belongs is called and the time the code branch is called. When a code branch in a function is called, then the jump path information for the code branch may indicate all called code branches and call orders since the function to which the code branch belongs was called. The jump path information of a code branch may be a sequence, and the sequence sequentially includes identification information of a function to which the code branch belongs, and identification information of code branches of all called functions from a time when the function to which the code branch belongs is called to a time when the code branch is called.
For example, assuming that a function func1 in the code of the original version is called after a test case of the code of the original version is tested on the code of the original version, an if else statement as a code branch in func1 is called, the contents printed to the log include: the identification information of the function func1, i.e., e026f40da33eae37, e026f40da33eae 37-L1664231211. L1664231211 is the identification information of the if else statement. It may be determined that the function func1 is called according to e026f40da33eae37-L1664231211 printed to the log, and the if else statement in the func1 is called, jump path information of the if else statement may be generated, the jump path information of the if else statement being a sequence of identification information of the function func1, i.e. e026f40da33eae37, the identification information L1664231211 in sequence.
Each test case of the code of the original version can correspond to one jump path information set respectively. The jump path information set corresponding to the test case of the code of the original version comprises the following steps: and after the test case is used for testing the code of the original version, the jump path information of each called code branch is obtained. The jump path information of a markup object indicates all the invoked markup objects and the invocation order between the time when the function to which the markup object belongs is invoked and the time when the markup object is invoked, when the markup object is invoked.
The jump path information of a tagged object may be a sequence, and when the tagged object is a function, the sequence only contains the identification information of the function. When the mark object is a code branch, the sequence sequentially contains the identification information of the function to which the code branch belongs and the identification information of all the called code branches of the function between the time when the function to which the code branch belongs is called and the time when the code branch is called.
In some optional implementation manners of this embodiment, when determining a test case of a code of an updated version based on the determined target markup object and the test case of the code of the original version, the test case of the code of the updated version for testing the code of the updated version may be selected from all the test cases of the original version based on the number of jump path information of the target markup object included in the jump path information set corresponding to the test case of the original version.
The test cases of each original version of the code may respectively correspond to a jump path information set. The jump path information set corresponding to the test case of the code of the original version comprises the following steps: and after the test case is used for testing the code of the original version, the jump path information of each called mark object is obtained. The jump path information of a markup object indicates all the invoked markup objects and the invocation order between the time when the function to which the markup object belongs is invoked and the time when the markup object is invoked, when the markup object is invoked.
For each target mark object, the respective jump path information of each target mark object can be determined. The jump path information of a target markup object may indicate all called markup objects and a call order between a time when a function to which the target markup object belongs is called and a time when the markup object is called when the target markup object is called.
When the test case of the code of the updated version for testing the code of the updated version is selected from the test cases of all the codes of the original version based on the number of the jump path information of the target mark object included in the jump path information set corresponding to the test case of the original version, the test case with the largest number of the jump path information of the target mark object included in the corresponding jump path information set may be selected from the test cases of all the codes of the original version. And the target mark objects except the target mark objects of which the jump path information is positioned in the jump path information set corresponding to the selected test case in all the target mark objects become the rest target mark objects. The test cases of the code of the original version except the test case picked up this time become the remaining test cases. Then, for the remaining target mark objects, the test case with the largest number of the jump path information of the remaining target mark objects contained in the corresponding jump path information set is selected from the test cases of the remaining original version of the code. And in the same way, for the remaining target mark objects after the last selection, the test case containing the largest amount of the jump path information of the remaining target mark objects is selected from the test cases of the remaining original version codes. Until there are no target marker objects remaining or no test cases to choose from.
Because the test case capable of testing the code branch can test the function to which the code branch belongs and all the called code branches belonging to the function before the code branch is called, when the test case of the code of the updated version for testing the code of the updated version is selected from the test cases of the code of all the original versions based on the number of the jump path information of the target mark object included in the jump path information set corresponding to the test case of the original version, it is equivalent to select the test case capable of testing the code branch as the target mark object from the test cases of the code of all the original versions.
The test case with the largest number of jump path information of the code branch as the target mark object contained in the corresponding jump path information set can be selected from all test cases of the code of the original version. And the code branch target mark objects which are target objects except the code branches which are target mark objects and are positioned in the jump path information set corresponding to the selected test case in all the target mark objects become the rest code branches which are target objects. The test cases of the code of the original version except the test case picked up this time become the remaining test cases. Then, for the remaining code branches as target mark objects, the test case with the largest number of the jump path information of the remaining code branches as target mark objects contained in the corresponding jump path information set is selected from the test cases of the remaining original version of code. And in the same way, for the code branches which are left after the last selection and are used as the target mark objects, the test case which contains the largest amount of jump path information of the left code branches which are used as the target mark objects is selected from the test cases of the left codes of the original versions. Until there are no code branches remaining as target marker objects or no test cases to choose from.
And 103, testing the code of the updated version by using the test case of the code of the updated version.
In this embodiment, after determining the test case for testing the code of the updated version of the code, the test case of the code of the updated version may be used to test the code of the updated version.
Referring to fig. 3, as an implementation of the methods shown in the above figures, the present application provides an embodiment of a code testing apparatus, which corresponds to the embodiment of the method shown in fig. 1.
As shown in fig. 3, the code testing apparatus of the present embodiment includes: an object determining unit 301, a use case determining unit 302, and a code testing unit 303. Wherein the object determination unit 301 is configured to determine a target markup object of all markup objects, wherein identification information of the markup object is generated based on at least part of a code of the markup object, and the identification information of the target markup object in the updated version of the code is different from the identification information of the target markup object in the original version of the code; the use case determining unit 302 is configured to determine a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version; the code testing unit 303 is configured to test the updated version of the code using the test cases of the updated version of the code.
In some optional implementations of this embodiment, marking the object includes: function, code branch in function.
In some optional implementations of this embodiment, the code testing apparatus further includes: a first identification information generation unit configured to generate identification information of a function based on attribute information of the function, the attribute information of the function including one or more of: the type of return value of the function, the function name of the function, the parameters of the function.
In some optional implementations of this embodiment, the code testing apparatus further includes: a second identification information generation unit configured to generate identification information of the code branch based on attribute information of the code branch, the attribute information of the code branch including one or more of: a branch type of the code branch, a parameter of the code branch, a statement in the code branch.
In some optional implementations of this embodiment, the code testing apparatus further includes: a pretest unit configured to add a log statement before a first statement of code marking an object in an original version of code, the log statement including: identification information of the mark object; testing the code of the original version by using a plurality of test cases; for each test case, determining a label object called after the code of the original version is tested by the test case based on the identification information output to the log after the code of the original version is tested by the test case.
In some optional implementations of this embodiment, the use case determining unit is further configured to: based on the number of jump path information of a target mark object included in a jump path information set corresponding to a test case of an original version, at least a part of the test case is selected from all the test cases of the original version to be used as a test case of a code of an updated version, wherein the jump path information set corresponding to the test case of the original version comprises: utilizing the jump path information of the mark object called after the test case of the original version tests the code of the original version, wherein the jump path information of the mark object indicates all the called mark objects and calling orders between the moment when the function to which the mark object belongs is called and the moment when the mark object is called
FIG. 4 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
As shown in fig. 4, the computer system includes a Central Processing Unit (CPU)401 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In the RAM403, various programs and data necessary for the operation of the computer system are also stored. The CPU 401, ROM 402, and RAM403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406; an output section 407; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. A driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 410 as necessary, so that a computer program read out therefrom is mounted into the storage section 408 as necessary.
In particular, the processes described in the embodiments of the present application may be implemented as computer programs. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising instructions for carrying out the method illustrated in the flow chart. The computer program can be downloaded and installed from a network through the communication section 409 and/or installed from the removable medium 411. The computer program performs the above-described functions defined in the method of the present application when executed by a Central Processing Unit (CPU) 401.
The present application further provides an electronic device that may be configured with one or more processors; a memory for storing one or more programs, the one or more programs may include instructions for performing the operations described in the above embodiments. The one or more programs, when executed by the one or more processors, cause the one or more processors to perform the operations described in the embodiments above.
The present application also provides a computer readable medium, which may be included in an electronic device; or the device can be independently arranged and not assembled into the electronic equipment. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: determining a target markup object of all the markup objects, wherein identification information of the markup object is generated based on at least part of the code of the markup object, and the identification information of the target markup object in the updated version of the code is different from the identification information of the target markup object in the original version of the code; determining a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version; and testing the code of the updated version by using the test case of the code of the updated version.
It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may include, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with a message execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with a message execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable messages for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer messages.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by a person skilled in the art that the scope of the invention as referred to in the present application is not limited to the embodiments with a specific combination of the above-mentioned features, but also covers other embodiments with any combination of the above-mentioned features or their equivalents without departing from the inventive concept. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (12)

1. A code testing method, comprising:
determining a target tagged object of all tagged objects based on the identification information of the tagged objects in the log, wherein the tagged object comprises: code branching in the function, the identification information of the tagged object being generated based on at least part of the code of the tagged object comprising: the identification information of the code branch is generated based on the attribute information of the code branch, and the attribute information of the code branch comprises one or more of the following items: the branch type of the code branch, the parameter of the code branch, the statement in the code branch, the identification information of the target mark object in the code of the updated version is different from the identification information of the target mark object in the code of the original version;
determining a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version;
and testing the code of the updated version by using the test case of the code of the updated version.
2. The method of claim 1, the tagging the object further comprising: a function.
3. The method of claim 2, further comprising:
generating identification information of the function based on the attribute information of the function, wherein the attribute information of the function comprises one or more of the following items: the type of return value of the function, the function name of the function, the parameters of the function.
4. The method according to one of claims 1-3, the method further comprising:
adding a log statement before a first statement of code of a markup object in an original version of code, the log statement comprising: identification information of the mark object;
testing the code of the original version by using a plurality of test cases;
for each test case, determining a label object called after the code of the original version is tested by the test case based on the identification information output to the log after the code of the original version is tested by the test case.
5. The method of claim 4, wherein determining the test case of the code of the updated version based on the determined target markup object and the test case of the code of the original version comprises:
based on the number of jump path information of a target mark object included in a jump path information set corresponding to a test case of an original version, at least a part of the test case is selected from all the test cases of the original version to be used as a test case of a code of an updated version, wherein the jump path information set corresponding to the test case of the original version comprises: and utilizing the jump path information of the mark object called after the test case of the original version tests the code of the original version, wherein the jump path information of the mark object indicates all the called mark objects and calling orders between the time when the function to which the mark object belongs is called and the time when the mark object is called.
6. A code testing apparatus comprising:
an object determination unit configured to determine a target markup object of all markup objects based on identification information of the markup objects in the log, wherein the markup object includes: code branching in the function, the identification information of the markup object being generated based on at least part of the code of the markup object, the identification information of the target markup object in the updated version of the code being different from the identification information of the target markup object in the original version of the code;
the case determining unit is configured to determine a test case of the code of the updated version based on the determined target mark object and the test case of the code of the original version;
the code testing unit is configured to test the code of the updated version by using the test case of the code of the updated version; and the apparatus further comprises:
a second identification information generation unit configured to generate identification information of the code branch based on attribute information of the code branch, the attribute information of the code branch including one or more of: a branch type of the code branch, a parameter of the code branch, a statement in the code branch.
7. The apparatus of claim 6, the marker object further comprising: a function.
8. The apparatus of claim 7, further comprising:
a first identification information generation unit configured to generate identification information of a function based on attribute information of the function, the attribute information of the function including one or more of: the type of return value of the function, the function name of the function, the parameters of the function.
9. The apparatus according to one of claims 6-8, the apparatus further comprising:
a pretest unit configured to add a log statement before a first statement of code marking an object in an original version of code, the log statement including: identification information of the mark object; testing the code of the original version by using a plurality of test cases; for each test case, determining a label object called after the code of the original version is tested by the test case based on the identification information output to the log after the code of the original version is tested by the test case.
10. The apparatus of claim 9, the use case determination unit further configured to: based on the number of jump path information of a target mark object included in a jump path information set corresponding to a test case of an original version, at least a part of the test case is selected from all the test cases of the original version to be used as a test case of a code of an updated version, wherein the jump path information set corresponding to the test case of the original version comprises: and utilizing the jump path information of the mark object called after the test case of the original version tests the code of the original version, wherein the jump path information of the mark object indicates all the called mark objects and calling orders between the time when the function to which the mark object belongs is called and the time when the mark object is called.
11. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method recited in any of claims 1-5.
12. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 5.
CN201811147512.5A 2018-09-29 2018-09-29 Code testing method and device Active CN109388568B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811147512.5A CN109388568B (en) 2018-09-29 2018-09-29 Code testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811147512.5A CN109388568B (en) 2018-09-29 2018-09-29 Code testing method and device

Publications (2)

Publication Number Publication Date
CN109388568A CN109388568A (en) 2019-02-26
CN109388568B true CN109388568B (en) 2020-05-15

Family

ID=65418999

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811147512.5A Active CN109388568B (en) 2018-09-29 2018-09-29 Code testing method and device

Country Status (1)

Country Link
CN (1) CN109388568B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113535533B (en) * 2020-04-15 2024-04-05 百度在线网络技术(北京)有限公司 Method, apparatus, device and storage medium for testing code
CN112948234B (en) * 2020-08-26 2023-02-21 深圳市明源云链互联网科技有限公司 Interface test method and device and electronic equipment
CN113297088B (en) * 2021-06-08 2023-11-07 北京百度网讯科技有限公司 Test method, test device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102024111A (en) * 2010-12-17 2011-04-20 互动在线(北京)科技有限公司 On-line scanning method for website programs
CN105302710A (en) * 2014-07-03 2016-02-03 腾讯科技(深圳)有限公司 Method and apparatus for determining test case in need of regression testing
CN107423214A (en) * 2017-04-18 2017-12-01 恒生电子股份有限公司 Software regression testing use-case acquisition methods, device and storage medium and electronic equipment
CN108255699A (en) * 2017-03-27 2018-07-06 平安科技(深圳)有限公司 regression testing method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7873944B2 (en) * 2006-02-22 2011-01-18 International Business Machines Corporation System and method for maintaining and testing a software application
US8589884B2 (en) * 2009-01-15 2013-11-19 Infosys Limited Method and system for identifying regression test cases for a software
CN101876939B (en) * 2009-11-20 2011-12-21 北京信息科技大学 System test method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102024111A (en) * 2010-12-17 2011-04-20 互动在线(北京)科技有限公司 On-line scanning method for website programs
CN105302710A (en) * 2014-07-03 2016-02-03 腾讯科技(深圳)有限公司 Method and apparatus for determining test case in need of regression testing
CN108255699A (en) * 2017-03-27 2018-07-06 平安科技(深圳)有限公司 regression testing method and device
CN107423214A (en) * 2017-04-18 2017-12-01 恒生电子股份有限公司 Software regression testing use-case acquisition methods, device and storage medium and electronic equipment

Also Published As

Publication number Publication date
CN109388568A (en) 2019-02-26

Similar Documents

Publication Publication Date Title
CN107506300B (en) User interface testing method, device, server and storage medium
CN108197036B (en) Method and apparatus for determining coverage information for incremental codes
US9152731B2 (en) Detecting a broken point in a web application automatic test case
CN110287702B (en) Binary vulnerability clone detection method and device
CN111507086B (en) Automatic discovery of translated text locations in localized applications
CN109388568B (en) Code testing method and device
US11327722B1 (en) Programming language corpus generation
US10726357B2 (en) Cross-platform program analysis using machines learning based on universal features
US11422917B2 (en) Deriving software application dependency trees for white-box testing
US20130179867A1 (en) Program Code Analysis System
CN112749081A (en) User interface testing method and related device
CN114115904B (en) Information processing method, device, server and storage medium
KR101979329B1 (en) Method and apparatus for tracking security vulnerable input data of executable binaries thereof
WO2013108161A1 (en) Manipulating source code patches
CN114138281A (en) Compiling method, device, equipment and medium of software engineering
CN110941547A (en) Automatic test case library management method, device, medium and electronic equipment
US10146530B1 (en) Simulating and evaluating code branch merge
CN116431520A (en) Test scene determination method, device, electronic equipment and storage medium
CN117370767B (en) User information evaluation method and system based on big data
CN113448614B (en) Software project code management method, device, storage medium and electronic equipment
CN113448869B (en) Method and device for generating test case, electronic equipment and computer readable medium
CN113946803A (en) Method and device for automatic bypass by having anti-debugging mechanism for target program
US11500619B1 (en) Indexing and accessing source code snippets contained in documents
CN117874118A (en) Feature data conversion method, device, electronic equipment and readable storage medium
CN112148590B (en) Method, device and equipment for determining code coverage rate

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
GR01 Patent grant
GR01 Patent grant