Embodiment
Below in conjunction with the accompanying drawings, embodiments of the invention are described.
The update method and device for the test script that the application is provided, it is adaptable to (be also referred to as to application program
System) carry out automatic test during, when application program is updated, the survey to test application program
The scene that training is originally updated.The application program that is particularly suitable for use in can influence test script just after being updated
Often during operation, the scene being updated to the test script of test application program.Application program herein can
Think third-party application program, or the application program that terminal device is carried, it can be included extremely
A few code segment.Test script is write, runs and adjusted in test platform (also referred to as test frame)
Examination, when test script is run in test frame, it is possible to realize and corresponding application program is carried out
Test;Test script is also to be made up of code line (referred to as testing code), wherein, a line or multirow are surveyed
Trying code is used to perform a test operation to application program, and this is used to perform application program one survey
The a line or multirow test code for trying operation be referred to as a testing procedure, and said one testing procedure is held
OK, then the operation of one or more code segments in application program may be caused, accordingly it is also possible to say every
Individual testing procedure is used to test a multiple code segments at least one code segment.
In actual applications, the operation of multiple test scripts may could realize the survey to an application program
Examination, and a test script is uniquely tested an application program.Accordingly it is also possible to say one
The multiple test scripts of application program correspondence, and test script one application program of correspondence.
In the automatic test course of application program, test script is normally based on what application program was write.
Therefore, when application program is updated, especially the application program can influence test script after being updated
During operation, it is necessary to which test script is updated.But because updating test script manually, can increase
The maintenance cost of test script, therefore the application proposes the update method of following test script.
The update method flow chart for the test script that Fig. 1 provides for a kind of embodiment of the application.Methods described
Executive agent can be the equipment with disposal ability:Server or system or device, e.g., are surveyed
Platform is tried, as shown in figure 1, methods described is specifically included:
Step 110, all or part of code segment at least one described code segment is monitored.
It is alternatively possible to perform step 110 before, first by the application program after renewal at least one
Code segment is fully loaded in the administration interface of test platform, in the administration interface, user can choose to
The partial code section of a few code segment is monitored.Specifically, if the selection for receiving user's input refers to
Order, then according to selection instruction, choose partial code section from least one code segment;And by the part generation
Code section is stored in the background data base of test platform, namely in the subsequently code segment of monitoring application program,
Only above-mentioned partial code section is monitored;Otherwise, whole code segments at least one code segment are stored
In the background data base of test platform, namely in the subsequently code segment of monitoring application program, to whole
Code segment is monitored.
Certainly, it is above-mentioned simply to be illustrated exemplified by once storing the process of part code segment;Work as needs
When being monitored to some code segments, then the operation of repeatedly storage part code segment is repeated;In addition,
It should also be noted that, a code segment can be included in partial code section, multiple codes can also be included
Section.
It is understood that having prestored the application program before updating in the background data base of test platform
At least one source code section, wherein, each source code section can be with the application program after renewal
One code segment is corresponding.The process of whole code segments at least one code segment of above-mentioned monitoring is:
Each code segment at least one code segment is read from the background data base of test platform, and is read with being somebody's turn to do
The corresponding source code section of code segment, both are compared afterwards, if first code section and corresponding original
Beginning code segment compares inconsistent, then it is assumed that first code section is changed.First code section herein can
Think any code segment at least one code segment.Similarly monitor the part generation at least one code segment
Code section process be:Each code in the code segment of part is read from the background data base of test platform
Section, and source code section corresponding with each code segment is read, both are compared afterwards, if part
First code section compares inconsistent with corresponding source code section in code segment, then it is assumed that first code section hair
Change is given birth to.
In fact, at least one code segment of application program, partial code section can be important, therefore,
Its renewal frequency is higher, and other code segments will not be substantially updated, or even if being updated also not
Any influence can be produced on the operation of test script, it is possible to need not be to renewal frequency than relatively low code
Section is monitored, and be monitored just for important partial code section, thus improves code segment
Monitoring efficiency.
Step 120, when monitor the first code in all or part of code segment section change
When, corresponding one or more testing procedures are read from default memory cell, wherein, it is described default
Memory cell be used to store the code segment of the application program and the testing procedure in the test script
Corresponding relation.
Illustrate herein, one or more test steps corresponding with each code segment at least one code segment
Suddenly it is pre-set.Specifically, above-mentioned corresponding relation can be stored in default memory cell.
In one example, default memory cell can be as shown in table 1.
Table 1
In table 1, application program includes four code segments, and four code segments are respectively:Code segment A, generation
Code section B, code segment C and code segment D;In addition, the application program two test scripts of correspondence, this two
Individual test script is respectively:Test script X and test script Y.With first code section for " code segment A "
Exemplified by for, it is " test script X ", and corresponding that corresponding test script can be read from table 1
Testing procedure is then " " testing procedure 1 " and " testing procedure 2 " in test script X ".
Certainly, in actual applications, it would however also be possible to employ other modes determine test corresponding with code segment
Step.
Step 130, the code changed in first code section is identified, to determine the hair
The change type of the code for changing.
It should be noted that when monitoring that first code section changes, namely monitoring the first generation
, can be to first code section and corresponding original generation when code section compares inconsistent with corresponding source code section
Inconsistent code is compared in code section, namely the code changed can be identified, to determine hair
The change type of the code for changing.In one example, when recognize first code section in user interface
When the title of (User Interface, UI) element changes, e.g., UI elements in first code section
It is entitled " button A ", and corresponding source code section in UI elements it is entitled " button B ",
Herein, the title of UI elements is the code changed, therefore the code that this can be changed
Change type is defined as " change of UI elements ";In another example, when recognize first code section
When the number of middle interface parameters changes, e.g., the service that application program is externally provided in first code section
The interface parameters of interface includes " parameter A ", " parameter B " and " parameter C ", and corresponding original generation
The interface parameters of service interface includes " parameter A " and " parameter B " in code section.Herein, service interface
Interface parameters is the code changed, therefore the change type for the code that this can change is true
It is set to " change of interface parameters ";By that analogy, it may be determined that the change of all codes changed
Type.
Step 140, when the change type of the code belongs to default change type, occurred according to described
The code of change is updated to one or more of testing procedures.
Herein, default change type includes but is not limited to the one or more in Types Below:User
Change, the change of interface parameters, the change of interface returning result and the change in path of interface UI elements
Deng.Herein, the change of UI elements and the change of interface parameters may refer to illustrating in step 130
It is bright.And the change of interface returning result can refer to that first code section is returned with corresponding source code section
As a result Type-Inconsistencies, are return numerical value etc. from Boolean type value changes are returned e.g..The change in path
It can refer to that having increased field or field name in database table newly changes.
It should be noted that in actual applications, default change type can be not limited to it is above-mentioned several,
Those skilled in the art can be rule of thumb default with needs, e.g., can have influence on test pin by all
The change type of the code of this operation is disposed as default change type, and the application is not construed as limiting to this.
In step 140, one or more of testing procedures are carried out according to the code changed
Update, be specially:
When the change type of the code belongs to the change of UI elements, by one or more of test steps
The UI elements before change in rapid replace with the UI elements after changing in the first code section;Or,
When the change type of the code belongs to the change of interface parameters, by one or more of tests
The interface parameters before change in step replaces with the interface parameters after changing in the first code section;Or
Person,
, will be one or more of when the change type of the code belongs to the change of interface returning result
Interface returning result before change in testing procedure replaces with the interface after changing in the first code section
Returning result;
When the change type of the code belongs to the change in path, by one or more of testing procedures
In change before path replacement for the first code section in change after path.
It should be noted that the test script of the application is used to test the application program before renewal,
Therefore, the information such as the title of UI elements, interface parameters, interface returning result and path in test script
It with the information in the application program before renewal is identical to be;And in order to be able to enter to the application program after renewal
The correct test of row, it is possible to which the above- mentioned information in one or more steps corresponding to first code section is carried out
Modification, to realize the renewal to test script.Such as previous example, can be by first code section corresponding one
" button B " is revised as " button A " to the title of UI elements in individual or multiple testing procedures;Can be by
Interface parameters " parameter A " and " parameter B " in the corresponding one or more testing procedures of first code section
It is revised as " parameter A ", " parameter B " and " parameter C " etc..
Based on the update method of above two test script, those skilled in the art can be to other change classes
The corresponding testing procedure of code segment of type is updated accordingly, and the application is not repeated again herein.Need
Bright, test platform, can be to each testing procedure when performing above-mentioned renewal process to test script
In renewal part correspondingly recorded.
It is to be appreciated that, whether the above-mentioned change type for judging code belongs to default change type, is exactly
In order to determine whether the change of the code can influence the operation of test script.Certainly, in actual applications,
Whether the change of the code can also be determined otherwise can influence the operation of test script, as long as
Can be correct, safely identify the code of the change of influence test script operation.Such as, it can combine
The corresponding testing procedure of code segment changed come determine the code changed whether can influence test pin
This operation.
Judge that the change of code does not interfere with test script by certain judgment mode it should be noted that working as
Operation when, then can ignore this change.It is understood that according to the code pair changed
After one or more testing procedures are updated, or, after the change for ignoring code, test platform
Monitoring process at least one code segment of the application program after renewal terminates;The monitoring process terminates it
Afterwards, it is possible to which the test script according to updating or not updating is tested to the application program after renewal;
After test process terminates, test platform can by the renewal part in each testing procedure and update or
The operation result for the test script not updated is sent to tester by way of mail, so as to tester
Member collects to the test result of the application program after renewal.
Certainly, in actual applications, it is also possible to there is test platform and failure is analyzed to the change type of code
Situation, at this moment, test platform can also notify tester by way of sending mail, so as to by
Tester is further analyzed.
The update method for the test script that the application is provided, monitor whole at least one code segment or
Partial code section;When monitoring that the section of the first code in all or part of code segment changes, from
Corresponding one or more testing procedures are read in default memory cell;To becoming in first code section
The code of change is identified, to determine the change type of the code changed;When the change type of code
When belonging to default change type, one or more testing procedures are carried out more according to the code changed
Newly.Namely in the application, directly can be according to changing when monitoring that code segment changes
Code is updated to corresponding testing procedure, it is achieved thereby that test script automatically updating and safeguards,
The workload of tester is alleviated, the testing efficiency of application program is improved.
With the update method of above-mentioned test script accordingly, a kind of test pin that the embodiment of the present application is also provided
This updating device, wherein, the test script is used to test corresponding application program, wherein,
The application program includes at least one code segment, and the test script includes at least one testing procedure,
Wherein, each testing procedure is used to carry out one or more of at least one code segment code segment
Test, as shown in Fig. 2 described device includes:Monitoring unit 201, reading unit 202, recognition unit
203 and updating block 204.
Monitoring unit 201, for monitoring all or part of code segment at least one described code segment.
Monitoring unit 201 specifically for:
At least one source code section of the application program before updating is obtained, wherein each source code
Section is corresponding with a code segment at least one described code segment;
Each code segment in all or part of code segment is compared with corresponding source code section
It is right, if first code section section compared with corresponding source code it is inconsistent, then it is assumed that the whole or portion
The section of the first code in code segment is divided to change.
Reading unit 202, for being monitored when monitoring unit 201 in all or part of code segment
When first code section changes, corresponding one or more test steps are read from default memory cell
Suddenly, wherein, the default memory cell is used to store the code segment of the application program and the test
The corresponding relation of testing procedure in script.
Recognition unit 203, for the code changed in first code section to be identified, with true
The change type of the fixed code changed.
Updating block 204, belongs to default for recognizing the change type of the code when recognition unit 203
Change type when, according to the code changed to one or more of testing procedures carry out more
Newly.
Wherein, the default change type includes but is not limited to the one or more in Types Below:
Change, the change of interface parameters, the change of interface returning result and the road of user interface UI elements
The change in footpath.
Updating block 204 specifically for:
When the change type of the code belongs to the change of UI elements, by one or more of test steps
The UI elements before change in rapid replace with the UI elements after changing in the first code section;Or,
When the change type of the code belongs to the change of interface parameters, by one or more of tests
The interface parameters before change in step replaces with the interface parameters after changing in the first code section;Or
Person,
, will be one or more of when the change type of the code belongs to the change of interface returning result
Interface returning result before change in testing procedure replaces with the interface after changing in the first code section
Returning result;
When the change type of the code belongs to the change in path, by one or more of testing procedures
In change before path replacement for the first code section in change after path.
Alternatively, described device also includes:Choose unit 205 and memory cell 206.
Unit 205 is chosen, for the selection instruction inputted according to user, from least one described code segment
Choose partial code section.
Memory cell 206, the partial code section for selection unit 205 to be chosen is stored in rear number of units
According in storehouse.
The function of each functional module of the embodiment of the present application device, can pass through each of above method embodiment
Step realizes that therefore, the specific work process for the device that the application is provided herein is not repeated again.
The updating device for the test script that the application is provided, monitoring unit 201 monitors at least one described generation
All or part of code segment in code section;When the first code section in all or part of code segment
When changing, reading unit 202 reads corresponding one or more tests from default memory cell
Step;The code changed in 203 pairs of the recognition unit first code section is identified, to determine
The change type of the code changed;When the change type of the code belongs to default change class
During type, updating block 204 enters according to the code changed to one or more of testing procedures
Row updates.Hereby it is achieved that automatically updating and safeguarding for test script, alleviates the work of tester
Amount, improves the testing efficiency of application program.
The updating device of the test script of the application can be embedded into existing test platform in the way of plug-in unit
In, on the basis of existing test platform, to the whole at least one code segment of application program
Or partial code section is monitored.
Professional should further appreciate that, be described with reference to the embodiments described herein
The object and algorithm steps of each example, can be come with electronic hardware, computer software or the combination of the two
Realize, in order to clearly demonstrate the interchangeability of hardware and software, in the above description according to function
Generally describe the composition and step of each example.These functions are come with hardware or software mode actually
Perform, depending on the application-specific and design constraint of technical scheme.Professional and technical personnel can be to every
Described function is realized in individual specific application using distinct methods, but it is this realize it is not considered that
Beyond scope of the present application.
The step of method or algorithm for being described with reference to the embodiments described herein, can use hardware, processing
The software module that device is performed, or the two combination are implemented.Software module can be placed in random access memory
(RAM), internal memory, read-only storage (ROM), electrically programmable ROM, electrically erasable ROM,
Any other form well known in register, hard disk, moveable magnetic disc, CD-ROM or technical field
Storage medium in.
Above-described embodiment, purpose, technical scheme and beneficial effect to the application are carried out
Be further described, should be understood that the embodiment that the foregoing is only the application and
, it is not used to limit the protection domain of the application, it is all within spirit herein and principle, done
Any modification, equivalent substitution and improvements etc., should be included within the protection domain of the application.