CN109388568A - Code test method and device - Google Patents

Code test method and device Download PDF

Info

Publication number
CN109388568A
CN109388568A CN201811147512.5A CN201811147512A CN109388568A CN 109388568 A CN109388568 A CN 109388568A CN 201811147512 A CN201811147512 A CN 201811147512A CN 109388568 A CN109388568 A CN 109388568A
Authority
CN
China
Prior art keywords
code
test case
function
version
branch
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.)
Granted
Application number
CN201811147512.5A
Other languages
Chinese (zh)
Other versions
CN109388568B (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.)
Baidu Online Network Technology Beijing Co Ltd
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

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 present application discloses code test method and device.One specific embodiment of this method includes: by the target label object in all tagged objects of determination;The test case of code based on the target label object and original version determined determines the test case of the code of more new version;The code of more new version is tested using the test case of the code of more new version.Realize the tagged object for only needing the test case for predefining original version that can test, in the subsequent code tester to the more new version of any version, code is automatically analyzed out to change the tagged object for needing to test again, test case of the corresponding test case as the code of more new version is determined from the test case of original version, reduces the expense of test process.Code can be accurately determined to change the code branch of any level for needing to test again, corresponding test case is selected and accurately tested.

Description

Code test method and device
Technical field
This application involves computer fields, and in particular to testing field more particularly to code test method and device.
Background technique
It needs test code using test case before code on-line.Currently, usually by utilizing survey Relevant information of the example on probation to the function exported after code tester, analyzing each test case manually can test Function, adjust test case based on the analysis results.However, code needs to constantly update with the extension of business, it is every to carry out one Secondary update obtains the code of a new version, is both needed to re-start test, the expense of test process is huge.
Summary of the invention
The embodiment of the present application provides code test method and device.
In a first aspect, the embodiment of the present application provides code test method, this method comprises: determining in all tagged objects Target label object, wherein at least partly code building of the identification information of tagged object based on tagged object, in more new edition The identification information of target label object in this code and the mark of the target label object in the code of original version are believed Breath is different;The test case of code based on the target label object and original version determined determines the generation of more new version The test case of code;The code of more new version is tested using the test case of the code of more new version.
Second aspect, the embodiment of the present application provide code tester device, which includes: object determination unit, are matched Be set to the target label object determined in all tagged objects, wherein the identification information of tagged object based on tagged object extremely Small part code building, in the identification information of the target label object in the code of more new version and in the code of original version Target label object identification information it is different;Use-case determination unit, be configured as based on the target label object determined and The test case of the code of original version determines the test case of the code of more new version;Code tester unit, is configured as The code of more new version is tested using the test case of the code of more new version.
Code test method and device provided by the embodiments of the present application pass through the target label in all tagged objects of determination Object, wherein at least partly code building of the identification information of tagged object based on tagged object, in the code of more new version Target label object identification information it is different from the identification information of target label object in the code of original version;It is based on The test case of the code of the target label object and original version determined determines that the test of the code of more new version is used Example;The code of more new version is tested using the test case of the code of more new version.Realizing only needs to predefine original The tagged object that the test case of beginning version can test, in the subsequent code tester to the more new version of any version, from The dynamic code that analyzes changes the tagged object for needing to test again, determines from the test case of original version corresponding Test case of the test case as the code of more new version, reduces the expense of test process.Code can be accurately determined The code branch for any level for needing to test again that changes, selects corresponding test case and is accurately tested.
Detailed description of the invention
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 shows the flow chart of one embodiment of the code test method according to the application;
The contrast effect schematic diagram that Fig. 2 shows identification informations in the code of two versions;
Fig. 3 shows the structural schematic diagram of one embodiment of the code tester device according to the application;
Fig. 4 is adapted for the structural schematic diagram for the computer system for realizing the electronic equipment of the embodiment of the present application.
Specific embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, part relevant to related invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Referring to FIG. 1, it illustrates the processes according to one embodiment of the code test method of the application.This method packet Include following steps:
Step 101, the target label object in all tagged objects is determined.
In the present embodiment, original version, more new version and are not specific to some version.In the code of a version Partial code modify after, which can be used as original version, and the code of the version can be used as original version Code, the code obtained after modification can be used as the code of more new version.For example, an item destination code is since the 1st version It is updated to the 5th version, the code of the 5th version is obtained after the partial code to the 4th version is modified, when to When the code of 5 versions is tested, the 4th version can be used as original version, and the 5th version can be used as more new version.
It in the present embodiment, include multiple tagged objects in the code of a version.The identification information of tagged object is based on At least partly code building of tagged object.When the code to a more new version is tested, can determine first all Target label object in tagged object, the identification information of the target label object in the code of more new version in original version The identification information of target label object in this code is different.
For example, a tagged object is a function, the letter is used as after all parameters of the function being combined Several identification informations has been previously added the identification information of the function in the code of the code of original version and more new version.When It is different from the function identification information in the code of more new version in the identification information of the function in the code of original version When, then the function can be used as target label object.
It in the present embodiment, can be with the identification information of each of the code of pre-recorded original version tagged object. When the code to more new version is tested, the code of more new version can be traversed, for example, traversing more new edition by syntax tree This code, obtains the identification information of each tagged object in the code of more new version.
It, can be with each of the code of pre-recorded original version function by taking all mark objects are function as an example Identification information, after the code of traversal more new version, the mark of each of code of available more new version function Information.The identification information of all functions in the code of original version may be constructed original identification information set.More new version The identification information of all functions in code, which may be constructed, updates identification information set.One in update identification information set When identification information is not appeared in original identification information set, then the identification information in the code of original version can be determined The identification information of affiliated function is different from the identification information of function belonging to the identification information in the code of more new version, The function can be used as target label object.
In some optional implementations of the present embodiment, tagged object includes: function, the code branch in function. Code branch can include but is not limited to: judge the code branch of type, the code branch of cyclical patterns.Such as judge type For if else sentence as a code branch, the code in if else sentence is the code of code branch.For Do statement can Using as a code branch, the code in for Do statement is the code of code branch.It may include in one function multiple Code branch, function terminate in a calling process from called initial time to this function call, in function extremely A few code branch can be called.It also can have subordinate relation between code branch.It in other words, can in a code branch To include multiple other codes branches.For example, an if else sentence is as a code branch, in the code branch also Code branch for Do statement is used as other if else sentences of code branch and one including one.
For a code branch as tagged object, when the code of the code branch in the code to original version Code branch when being modified, in the code of the code branch in the code of original version and the code of more new version Code it is different, correspondingly, the identification information of the code branch in the code of original version and the code in more new version In code branch identification information it is different, may thereby determine that the code branches into target label object.
Referring to FIG. 2, the contrast effect schematic diagram that it illustrates identification informations in the code of two versions.
The first sentence of the function of entitled func2 is log sentence, that is, Log sentence, interior in the quotation marks in Log sentence Hold the identification information a43ef43c493edb3f for the function for being the entitled func2.The function of entitled func2 includes two For Do statement.Each for Do statement is a code branch, each for Do statement is to mark as one Remember object.From top to bottom, the 2nd for Do statement is located in the 1st for Do statement.Head in 2nd for Do statement A sentence is Log sentence, the identification information+the 2 for the function that the content in quotation marks in the Log sentence is the entitled func2 The identification information of a for Do statement, the identification information of the 2nd for Do statement is based on the generation in the 2nd for Do statement Code generates.It include System.out.println sentence in the code of 2nd for Do statement.In the code of original version, the Content in the quotation marks of System.out.println sentence in 2 for Do statements is " * ".In the code of more new version, Content in the quotation marks of System.out.println sentence in 2nd for Do statement is " # ".Since the 2nd for is followed The identification information of ring sentence is based on the code building in the 2nd for Do statement, the 2nd for circulation in the code of original version The code of sentence is different with the 2nd code of for Do statement in the code of more new version, therefore, in the code of original version The identification information of 2nd for Do statement is different from the 2nd identification information of for Do statement in the code of more new version.It is former The identification information of the 2nd for Do statement is L909957905 in the code of beginning version.2nd in the code of more new version The identification information of Do statement is L709953848.By comparing the identification information of code branch, original version can be determined The identification information of the identification information of 2nd for Do statement and the 2nd for Do statement in the code of more new version in code Difference determines that the 2nd for Do statement is that target marks object, in another words, it is determined that the code of the 2nd for Do statement occurs Variation, when the code to more new version is tested, needs to test the 2nd for Do statement again, correspondingly, The test case of the more new version selected from the test case of the code of original version needs to recycle the 2nd for Sentence is tested.By comparing the identification information of code branch, the identification information that can be accurately determined in each level exists The code of original version neutralizes code branch different in the code of more new version, that is, is accurately determined the code hair of each level The code branch for changing, to when the code to more new version is tested, from the test case of the code of original version In select more new version test case needs the changed code branch of code can be tested.
It, can be based on the code of function for each function in some optional implementations of the present embodiment In the return Value Types of function, the function name of function, the parameter of function, the Exception Type of function dished out etc., calculate Kazakhstan Uncommon value, using calculated cryptographic Hash as the identification information of function.For example, can be by return Value Types, the function of a function The information such as name, function parameter, the Exception Type dished out are combined, and are obtained a combined information, are calculated group using MD5 algorithm The corresponding cryptographic Hash of information is closed, by the calculated identification information as the function.After calculating the identification information of function, The log sentence that the identification information comprising function can be write, by log sentence be added to the first sentence in the code of function it Before, i.e., using log sentence as the first sentence in the code of function.To which log can be first carried out when function is called The identification information of sentence, the function in log sentence can be printed in log.
It, can be based on the branch of code branch for code branch in some optional implementations of the present embodiment Type, the parameter in the code branch, the sentence in the code branch, layer depth of the code branch etc. obtain the second association letter Breath.For example, can for a code branch, can by the branch pattern of the code branch, the code branch parameter, should Sentence, the layer depth of the code branch in code branch etc. are combined, and obtain the second related information, can calculate the second association The corresponding cryptographic Hash of information, using calculated cryptographic Hash as the identification information of the code branch.For the every of each function One code branch can write the log language of the identification information comprising the function and the identification information of the code branch respectively Sentence, log sentence is added to before the first sentence in the code of code branch.To, when code branch is called, meeting Log sentence is first carried out, the identification information of the function in log sentence and the identification information of code branch can be printed to log In.
Step 102, the test case of the code based on the target label object and original version determined, determines to update The test case of the code of version.
In the present embodiment, each of multiple test cases of code of original version original version can be advanced with The test case of this code respectively tests the code of original version, determines the use of each test case respectively to original The tagged object that the code of beginning version is called after being tested.
When tagged object includes function, code branch in function, function is in a calling process from called Initial time terminates to this function call, at least one code branch in function can be called.When one original version of utilization The test case of this code to the code of original version carry out one function of test it is called when, then it is original can will to establish this The corresponding relationship of the identification information of the test case and function of the code of version, meanwhile, when the function is called in the function At least one code branch it is called, can establish the test case and at least one code point of the code of the original version The corresponding relationship of branch.The test case of the code of one original version can repeatedly call the same function during the test, Call at least one code branch during function called each time.Not quilt during the same function of the calling of homogeneous The code branch of calling can identical or part it is identical, can also be entirely different.
The letter being called when being tested using the test case of the code of an original version the code of original version Several identification informations can be referred to as the identification information of the corresponding function of code of the original version.Utilize original version The identification information for the code branch being called when the test case of code tests the code of original version can be referred to as The identification information of the corresponding code branch of the code of the original version.In the test case of the code using each original version After testing the code of original version, the test case of the code of each original version can correspond to multiple functions Identification information, the test case of the code of each original version can correspond to the identification information of multiple code branches.
In the present embodiment, can based on the test case of the code of the target label object and original version determined, Determine the test case of the code of more new version.
By taking all target label objects are function as an example, for a function as target label object, original The function identification information in the code of version is different from the identification information of the function in the code of more new version, therefore, needs Determine that corresponding test case tests the function again.Determine all test cases of the code of more new version The test case for determining can be tested again all functions as target label object can be equivalent to.Work as determination When the test case of the code of more new version, correspondence can be selected from the test case of the code of all original versions first The function as target label object the most test case of identification information.In other words, due to the generation of an original version The identification information of the corresponding function of test case of code is the test case in the code using the original version to original version Code function called when being tested identification information, selected from the test case of the code of all original versions The most test case of the identification information of corresponding function is equivalent to be chosen from the test case of the code of all original versions The most test case of the quantity for the function as target label object that can be tested out.Then, mesh is used as remaining The function for marking tagged object, selected from the test case of the code of remaining original version can test it is remaining as mesh Mark the most test case of the quantity of the function in the function of tagged object.And so on, each time for last selection The remaining function as target label object afterwards, selecting from the test case of the code of remaining original version can be with Test the most test case of the quantity of the function in the remaining function as target label object.Until without remaining conduct The test case of the function of target label object or the original version that can not be chosen.
It, can be in each of code of original version label pair in some optional implementations of the present embodiment Log sentence is separately added into before the first sentence of elephant.Log sentence includes: the identification information of tagged object.It can use multiple Test case tests the code of original version.For the test case of the code of each original version, based on utilization The test case of the code of original version is output to the identification information of log after being tested the code of original version, really Surely the tagged object being called after being tested using the test case of the code of original version the code of original version.It is right It can also be wrapped in code branch as the identification information in the log sentence of the first sentence of code branch in addition to code branch Include the identification information of function belonging to code branch.In the process that the test case of the code using original version is tested In, when function is called, the log sentence of the first sentence as function is performed, and the identification information of function can then export To log.When code branch is called, the identification information of code branch can then be output to log.It can be respectively according to utilization The test case of the code of each original version is output to the function in log after being tested the code of original version Identification information, code branch identification information, determine the use of the test case of the code of each original version respectively to original The function and code branch that the code of beginning version is called after being tested.It can be further to the code of original version Each test case determines the use of each when the test case of the code of original version tests the code of original version A tagged object jumps routing information.
The routing information that jumps of one function can be the identification information of the function.Believe in the path that jumps of one code branch Breath instruction function belonging to the code branch is called play the code branch it is called at the time of between it is all called Code branch and call sequence.When a code branch in a function is called, then the code branch jumps path Information can indicate that the called code branch of playing of the function belonging to the code branch is called all called codes Branch and call sequence.The routing information that jumps of one code branch can be a sequence, successively include the code in sequence The identification information of function belonging to branch, it is called from function belonging to the code branch at the time of it is called to the code branch At the time of between all called functions code branch identification information.
For example, it is assumed that a test case of the code of original version is to original version after the code tester of original version Function func1 in code is called, and an if else sentence as code branch in func1 is called, prints to day The content of will includes: identification information i.e. e026f40da33eae37, e026f40da33eae37- of function func1 L1664231211.L1664231211 is the identification information of the if else sentence.It can be according to being printed to log E026f40da33eae37-L1664231211 determines that function func1 is called, also, the if else sentence in func1 Called, the if else sentence can be generated jumps routing information, and the routing information that jumps of the if else sentence is One sequence, the identification information in the sequence are followed successively by identification information i.e. e026f40da33eae37, if of function func1 The identification information L1664231211 of else sentence.
Each test case of the code of original version can respectively correspond one and jump routing information set.One original The corresponding routing information set that jumps of the test case of the code of beginning version includes: the generation using the test case to original version After code is tested each called code branch is respective jumps routing information.One tagged object jumps path Information indicates at the time of when the tagged object is called, the function belonging to the tagged object is called to the tagged object quilt All called tagged objects and call sequence between at the time of calling.
The routing information that jumps of one tagged object can be a sequence, when tagged object is a function, sequence In only include the function identification information.When tagged object is a code branch, then successively comprising the code point in sequence It is called at the time of propping up the identification information of affiliated function, be called from function belonging to the code branch to the code branch The identification information of the code branch of all called functions between moment.
In some optional implementations of the present embodiment, when based on the target label object determined and original version Code test case, determine more new version code test case when, can be based on the test case pair of original version That answers jumps the quantity for jumping routing information for the target label object for including in routing information set, from all original versions The test case of the code for the more new version tested for the code to more new version is selected in test case.
The test case of the code of each original version can respectively correspond one and jump routing information set.One original The corresponding routing information set that jumps of the test case of the code of beginning version includes: the generation using the test case to original version After code is tested each called tagged object is respective jumps routing information.One tagged object jumps path Information indicates at the time of when the tagged object is called, the function belonging to the tagged object is called to the tagged object quilt All called tagged objects and call sequence between at the time of calling.
Can be determined by each target label object is respective respectively and jump path letter for each target label object Breath.One target label object jumps routing information and can indicate when the target label object is called in the target label pair All called tagged objects and calling between at the time of as being called at the time of affiliated function is called to tagged object Order.
The target label object for including in routing information set is jumped when the test case based on original version is corresponding The quantity for jumping routing information is selected from the test case of the code of all original versions for the code to more new version It, can be first from the test case of the code of all original versions when the test case of the code for the more new version tested Select the most survey of the corresponding quantity for jumping routing information for jumping the target label object for including in routing information set Example on probation.Believe in addition to jumping routing information positioned at the corresponding path that jumps of the test case selected in all target label objects The target label object except target label object in breath set becomes remaining target label object.In addition to this is selected Test case except original version code test case become remaining test case.Then, for remaining target Tagged object includes from corresponding jump in routing information set is selected in the test case of the code of remaining original version Remaining target label object the most test case of the quantity for jumping routing information.And so on, each time for upper It is primary choose after remaining target label object, selected from the test case of the code of remaining original version and include Remaining target label object the most test case of the quantity for jumping routing information.Until without remaining target label pair As or the test case that can not choose.
Test case as that can test code branch can test function belonging to the code branch and arrive the code All called code branches for belonging to the function before branch is called, therefore, when the test case based on original version The corresponding quantity for jumping routing information for jumping the target label object that routing information set includes, from all original versions The test case of the code for the more new version tested for the code to more new version is selected in the test case of code When, it is equivalent to the code for selecting and being tested as target label object from the test case of the code of all original versions The test case of branch.
It can be selected from the test case of the code of all original versions first and corresponding jump routing information set In be included as target label object code branch the most test case of the quantity for jumping routing information.All targets It is located at the corresponding conduct jumped in routing information set of test case selected in addition to jumping routing information in tagged object The code branch target tagged object as target object except the code branch of target label object becomes remaining conduct The code branch of target object.The test case of the code of original version other than the test case that this is selected becomes Remaining test case.Then, for the remaining code branch as target label object, from the generation of remaining original version It is selected in the test case of code and corresponding jumps the remaining generation as target label object for including in routing information set The most test case of the quantity for jumping routing information of code branch.And so on, it is surplus after being chosen each time for the last time The remaining code branch as target label object, selects from the test case of the code of remaining original version and includes The remaining code branch as target label object the most test case of the quantity for jumping routing information.Until without surplus Remaining code branch as target label object or the test case that can not be chosen.
Step 103, the code of more new version is tested using the test case of the code of more new version.
In the present embodiment, in the test case of the code for the more new version for determining the code for testing more new version Later, the test case that can use the code of more new version tests the code of more new version.
Referring to FIG. 3, this application provides a kind of code tester devices as the realization to method shown in above-mentioned each figure One embodiment, the Installation practice are corresponding with embodiment of the method shown in FIG. 1.
As shown in figure 3, the code tester device of the present embodiment includes: object determination unit 301, use-case determination unit 302, Code tester unit 303.Wherein, object determination unit 301 is configured to determine that the target label object in all tagged objects, Wherein, at least partly code building of the identification information of tagged object based on tagged object, the mesh in the code of more new version The identification information for marking tagged object is different from the identification information of target label object in the code of original version;Use-case determines Unit 302 is configured as the test case of the code based on the target label object and original version determined, determines to update The test case of the code of version;Code tester unit 303 is configured as the test case using the code of more new version to more The code of new version is tested.
In some optional implementations of the present embodiment, tagged object includes: function, the code branch in function.
In some optional implementations of the present embodiment, code tester device further include: first identifier information generates Unit, is configured as the attribute information based on function, the identification information of generating function, and the attribute information of function includes with the next item down It is or multinomial: the return Value Types of function, the function name of function, the parameter of function.
In some optional implementations of the present embodiment, code tester device further include: second identifier information generates Unit is configured as the attribute information based on code branch, generates the identification information of code branch, the attribute information of code branch Including following one or more: the branch pattern of code branch, the parameter of code branch, the sentence in code branch.
In some optional implementations of the present embodiment, code tester device further include: pretest unit is configured For log sentence, the log sentence packet are added before the first sentence of the code of the tagged object in the code of original version It includes: the identification information of tagged object;It is tested using code of multiple test cases to original version;For each test Use-case is output to the identification information of log, determined the use of after being tested based on code of the test case to original version The tagged object that test case is called after being tested the code of original version.
In some optional implementations of the present embodiment, use-case determination unit is configured to: based on original The corresponding quantity for jumping routing information for jumping the target label object that routing information set includes of the test case of version, from At least partly test case of the test case as the code of more new version is selected in the test case of all original versions, In, the corresponding routing information set that jumps of the test case of original version includes: the test case using original version to original The tagged object being called after the code tester of version jumps routing information, and the routing information instruction that jumps of tagged object is worked as At the time of the function belonging to the tagged object is called when tagged object is called to the tagged object be called when All called tagged objects and call sequence between quarter
Fig. 4 shows the structural schematic diagram for being suitable for the computer system for the electronic equipment for being used to realize the embodiment of the present application.
It, can be according to being stored in read-only storage as shown in figure 4, computer system includes central processing unit (CPU) 401 Program in device (ROM) 402 is executed from the program that storage section 408 is loaded into random access storage device (RAM) 403 Various movements appropriate and processing.In RAM403, it is also stored with various programs and data needed for computer system operation. CPU 401, ROM 402 and RAM 403 are connected with each other by bus 404.Input/output (I/O) interface 405 is also connected to always Line 404.
I/O interface 405: importation 406 is connected to lower component;Output par, c 407;Storage section including hard disk etc. 408;And the communications portion 409 of the network interface card including LAN card, modem etc..Communications portion 409 is via all As the network of internet executes communication process.Driver 410 is also connected to I/O interface 405 as needed.Detachable media 411, Such as disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 410, in order to from thereon The computer program of reading is mounted into storage section 408 as needed.
Particularly, process described in embodiments herein may be implemented as computer program.For example, the application Embodiment includes a kind of computer program product comprising carries computer program on a computer-readable medium, the calculating Machine program includes the instruction for method shown in execution flow chart.The computer program can be by communications portion 409 from net It is downloaded and installed on network, and/or is mounted from detachable media 411.In the computer program by central processing unit (CPU) When 401 execution, the above-mentioned function of limiting in the present processes is executed.
Present invention also provides a kind of electronic equipment, which can be configured with one or more processors;Storage Device may include in one or more programs to execute described in above-described embodiment for storing one or more programs The instruction of operation.When one or more programs are executed by one or more processors, so that one or more processors execute It is operated described in above-described embodiment.
Present invention also provides a kind of computer-readable medium, which, which can be in electronic equipment, is wrapped It includes;It is also possible to individualism, without in supplying electronic equipment.Above-mentioned computer-readable medium carries one or more Program, when one or more program is executed by electronic equipment, so that electronic equipment: determining the target in all tagged objects Tagged object, wherein at least partly code building of the identification information of tagged object based on tagged object, in the generation of more new version The identification information of target label object in code is different from the identification information of target label object in the code of original version; The test case of code based on the target label object and original version determined determines the test of the code of more new version Use-case;The code of more new version is tested using the test case of the code of more new version.
It should be noted that computer-readable medium described herein can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example may include but unlimited In the system of electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor, device or device, or any above combination.Computer can The more specific example for reading storage medium can include but is not limited to: electrical connection, portable meter with one or more conducting wires Calculation machine disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device or The above-mentioned any appropriate combination of person.In this application, computer readable storage medium can be it is any include or storage program Tangible medium, which can be executed system by message, device or device use or in connection.And in this Shen Please in, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, In carry computer-readable program code.The data-signal of this propagation can take various forms, including but not limited to Electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be computer-readable Any computer-readable medium other than storage medium, the computer-readable medium can send, propagate or transmit for by Message executes system, device or device use or program in connection.The journey for including on computer-readable medium Sequence code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use The executable message of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it to infuse Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer message Combination realize.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from the inventive concept, it is carried out by above-mentioned technical characteristic or its equivalent feature Any combination and the other technical solutions formed.Such as features described above has similar function with (but being not limited to) disclosed herein Can technical characteristic replaced mutually and the technical solution that is formed.

Claims (14)

1. a kind of code test method, comprising:
Determine the target label object in all tagged objects, wherein the identification information of tagged object based on tagged object extremely Small part code building, in the identification information of the target label object in the code of more new version and in the code of original version Target label object identification information it is different;
The test case of code based on the target label object and original version determined determines the code of more new version Test case;
The code of more new version is tested using the test case of the code of more new version.
2. according to the method described in claim 1, tagged object includes: function, the code branch in function.
3. according to the method described in claim 2, the method also includes:
Attribute information based on function, the identification information of generating function, the attribute information of function include following one or more: letter Several return Value Types, the function name of function, the parameter of function.
4. according to the method described in claim 3, the method also includes:
Based on the attribute information of code branch, the identification information of code branch is generated, the attribute information of code branch includes following It is one or more: the branch pattern of code branch, the parameter of code branch, the sentence in code branch.
5. method described in one of -4 according to claim 1, the method also includes:
Log sentence, the log sentence are added before the first sentence of the code of the tagged object in the code of original version It include: the identification information of tagged object;
It is tested using code of multiple test cases to original version;
For each test case, log is output to after being tested based on code of the test case to original version Identification information determines the use of the tagged object being called after test case tests the code of original version.
6. according to the method described in claim 5, the test of the code based on the target label object and original version determined Use-case determines that the test case of the code of more new version includes:
Test case based on original version is corresponding jump target label object that routing information set includes jump path The quantity of information selects at least partly code of the test case as more new version from the test case of all original versions Test case, wherein the corresponding routing information set that jumps of the test case of original version includes: the survey using original version Example on probation jumps routing information to tagged object called after the code tester of original version, and tagged object jumps road Diameter information indicates at the time of when tagged object is called, the function belonging to the tagged object is called to the label pair All called tagged objects and call sequence between at the time of as being called.
7. a kind of code tester device, comprising:
Object determination unit, the target label object being configured to determine that in all tagged objects, wherein the mark of tagged object At least partly code building of the information based on tagged object, the identification information of the target label object in the code of more new version It is different from the identification information of target label object in the code of original version;
Use-case determination unit is configured as the test case of the code based on the target label object and original version determined, Determine the test case of the code of more new version;
Code tester unit is configured as surveying the code of more new version using the test case of the code of more new version Examination.
8. device according to claim 7, tagged object includes: function, the code branch in function.
9. device according to claim 8, described device further include:
First identifier information generating unit, is configured as the attribute information based on function, the identification information of generating function, function Attribute information includes following one or more: the return Value Types of function, the function name of function, the parameter of function.
10. device according to claim 9, described device further include:
Second identifier information generating unit is configured as the attribute information based on code branch, generates the mark letter of code branch Breath, the attribute information of code branch includes following one or more: the branch pattern of code branch, the parameter of code branch, generation Sentence in code branch.
11. the device according to one of claim 7-10, described device further include:
Pretest unit is configured as that day is added before the first sentence of the code of the tagged object in the code of original version Will sentence, the log sentence include: the identification information of tagged object;Using multiple test cases to the code of original version into Row test;For each test case, day is output to after being tested based on code of the test case to original version The identification information of will determines the use of the tagged object being called after test case tests the code of original version.
12. device according to claim 11, use-case determination unit is configured to: the test based on original version The corresponding quantity for jumping routing information for jumping the target label object that routing information set includes of use-case, from all original versions At least partly test case of the test case as the code of more new version is selected in this test case, wherein original version This test case is corresponding, and to jump routing information set include: the test case using original version to the code of original version The tagged object being called after test jumps routing information, and tagged object jumps routing information instruction when tagged object quilt Own between at the time of called to the tagged object at the time of function belonging to the tagged object is called when calling Called tagged object and call sequence.
13. a kind of electronic equipment characterized by comprising
One or more processors;
Memory, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors Realize such as method as claimed in any one of claims 1 to 6.
14. a kind of computer-readable medium, which is characterized in that be stored thereon with computer program, which is characterized in that the program quilt Such as method as claimed in any one of claims 1 to 6 is realized when processor executes.
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 true CN109388568A (en) 2019-02-26
CN109388568B 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)

Cited By (3)

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

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876939A (en) * 2009-11-20 2010-11-03 北京信息科技大学 System test method and device
US7873944B2 (en) * 2006-02-22 2011-01-18 International Business Machines Corporation System and method for maintaining and testing a software application
CN102024111A (en) * 2010-12-17 2011-04-20 互动在线(北京)科技有限公司 On-line scanning method for website programs
US8589884B2 (en) * 2009-01-15 2013-11-19 Infosys Limited Method and system for identifying regression test cases for a software
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

Patent Citations (7)

* 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
CN101876939A (en) * 2009-11-20 2010-11-03 北京信息科技大学 System test method and device
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

Cited By (6)

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

Also Published As

Publication number Publication date
CN109388568B (en) 2020-05-15

Similar Documents

Publication Publication Date Title
CN109960653A (en) Regression testing method, device, equipment and storage medium
CN101788907B (en) Automatic generation method for combination service simplified test case and device therefor
CN109388568A (en) Code test method and device
CN108197036A (en) For determining the method and apparatus of the coverage rate information of incremental code
CN108595342B (en) Unit testing method and device
US20080295069A1 (en) User-extensible rule-based source code modification
CN103761189B (en) Test case management method and system
CN108256335B (en) Method and apparatus for detecting loophole
CN103164334A (en) System and method for detecting breaking point in web application automatic test case
US11055208B1 (en) Systems and methods for automatically assessing and conforming software development modules to accessibility guidelines in real-time
CN109739526A (en) Code update method and device
CN107679059A (en) Matching process, device, computer equipment and the storage medium of service template
CN109002474A (en) A kind of data migration method and device
CN109558525A (en) A kind of generation method of test data set, device, equipment and storage medium
CN109871317A (en) Code quality analysis method and device, storage medium and electronic equipment
CN105512021A (en) Method and device for Diff analysis used for software testing
CN108255702A (en) A kind of test case creation method, apparatus, equipment and storage medium
CN110244967A (en) Method for updating edition and device
CN110287696A (en) A kind of detection method, device and the equipment of the shell process that rebounds
CN108959087A (en) test method and device
CN108595313A (en) Daily record generation method, device, electronic equipment and the storage medium of application program
CN109960696A (en) A kind of configuration method, equipment and the storage medium of intelligence contract
CN111966580A (en) Automatic testing method, device, equipment and storage medium based on artificial intelligence
CN109032850A (en) Field device debugging system and field device adjustment method
CN116560683A (en) Software updating method, device, equipment and storage medium

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