Summary of the invention
The invention provides the method and system that the location returns use-case, in order to fast, accurately orient the use-case that needs recurrence, raising returns efficient.
Technical scheme provided by the invention comprises:
A kind of method that returns use-case of locating comprises:
A behind each use-case end of run, generates the mapping relations that comprise following content: the sign of the statement line that is covered by use-case in the sound code file that the sign of this use-case, this use-case are correlated with and this sound code file;
B, when the information of statement line in the sound code file occurs to revise, the mapping relations that keyword search comprises this key word that are designated with this statement line, if find the mapping relations that comprise this key word, use-case corresponding to use-case sign in the mapping relations that then this found needing to be defined as the use-case of recurrence, returns the use-case that this is determined.
A kind of system that returns use-case of locating comprises:
The mapping relations apparatus for establishing is used for generating the mapping relations that comprise following content behind each use-case end of run: the sign of the statement line that is covered by use-case in the sound code file that the sign of this use-case, this use-case are correlated with and this sound code file;
Return use-case and determine device, it comprises searches unit and determining unit, wherein,
The described unit of searching is used for when the information of sound code file statement line occurs to revise, with the mapping relations that keyword search comprises this key word that are designated of this statement line;
Described determining unit is used for described when searching the unit and finding the mapping relations that comprise this key word, and use-case corresponding to the sign of the use-case in these mapping relations that find needing to be defined as the use-case that returns, returns the use-case that this is determined.
As can be seen from the above technical solutions, among the present invention, when the information of statement line occurs to revise in sound code file, the present invention is with the mapping relations that keyword search comprises this key word that are designated of this statement line, only use-case corresponding to the sign of the use-case in the mapping relations that find needing to be defined as the use-case of recurrence, this can fast, accurately orient the use-case that needs recurrence than prior art;
And the present invention only returns use-case corresponding to the sign of the use-case in the mapping relations that find, and all sound code file is relevant than prior art use-cases return, and this has greatly reduced use-case and has returned quantity, improves to return efficient.
Embodiment
In order to make the purpose, technical solutions and advantages of the present invention clearer, describe the present invention below in conjunction with the drawings and specific embodiments.
Method provided by the invention comprises flow process shown in Figure 2:
Referring to Fig. 2, the process flow diagram that Fig. 2 provides for the embodiment of the invention.As shown in Figure 2, this flow process can may further comprise the steps:
Step 201 behind each use-case end of run, generates the mapping relations that comprise following content: the sign of the statement line that is covered by use-case in the sound code file that the sign of this use-case, this use-case are correlated with and this sound code file.
In this step 201, a use-case can be simultaneously relevant with a plurality of sound code files.
Step 202, when the information of statement line in the sound code file occurs to revise, the mapping relations that keyword search comprises this key word that are designated with this statement line, if find the mapping relations that comprise this key word, use-case corresponding to use-case sign in the mapping relations that then this found needing to be defined as the use-case of recurrence, returns the use-case that this is determined.
For making flow process shown in Figure 2 clearer, the below lifts a specific embodiment and is described:
Based on step 201, if it is all relevant with same sound code file (being designated as sound code file 1) to use-case 5 then to obtain use-case 1, specifically as shown in Figure 3.Wherein, obtaining following mapping relations for each use-case is: use-case 1, sound code file 1, mapping relations between the 10th to 15 row of use-case 1 covering sound code file 1, use-case 2, sound code file 1, mapping relations between the 20th to 25 row of use-case 2 covering sound code files 1, use-case 3, sound code file 1, mapping relations between the 30th to 35 row of use-case 3 covering sound code files 1, use-case 4, sound code file 1, mapping relations between the 40th to 45 row of use-case 4 covering sound code files 1, and use-case 5, sound code file 1, mapping relations between the 50th to 55 row of use-case 5 covering sound code files 1.
Then, walk to code information (abbreviation information) in 25 row when needing according to the actual requirements to revise the 20th of sound code file 1, then based on the description of step 202, can be the 20th to walk to the mapping relations that 25 behavior keyword searches comprise this key word in the sound code file 1, so, can obtain only having in the mapping relations of use-case 2 correspondences and comprise this key word, so, use-case (being use-case 2) corresponding to the sign of the use-case in these mapping relations that find needing to be defined as the use-case of recurrence, and other use-cases are such as use-case 1, use-case 3,5 of use-case 4 and use-cases do not need to return, specifically can be referring to shown in Figure 4.In Fig. 4, because use-case 2 needs recurrence, and other use-cases do not need to return, and for ease of distinguishing, represent use-case 2 with thicker solid line, and other use-cases then represent with relatively thin solid line.
As seen in Figure 4, when the 20th of sound code file 1 walked to information in 25 row and occur to revise, the present invention only need to return and cover the 20th use-case 2 that walks in 25 row, but not sound code file 1 all relevant use-cases are returned, this has greatly reduced use-case and has returned quantity, improves to return efficient.
Need to prove, among the present invention, if to comprise this statement line sign be the mapping relations of key word not finding, then determine not exist the use-case of needs recurrence, and further orient this statement line sign, and this statement line identifies residing sound code file, this can be kept at setting without in the use-case sound code file, realized by the find_modify_line_caseid.sh script; Do like this, purpose is to make the user design targetedly use-case such as the tester according to statement line sign and the sound code file oriented, reduces testing cost, improves testing efficiency.
Further, can also provide the suggestion that increases new use-case for this statement line sign and the residing sound code file of this statement line information.
Based on top description, describe the present invention below by flow process shown in Figure 5:
Referring to Fig. 5, Fig. 5 is detail flowchart provided by the invention.As shown in Figure 5, this flow process can may further comprise the steps:
Step 501 behind each use-case end of run, records the sign of this use-case.
Record in this step 501 can be by carrying out behind execution or the use-case automatic operating after the tested program operation.In the use-case identification information file that wherein, the identification record of this use-case extremely can be arranged.
Step 502 generates the relevant sound code file of this use-case.
This step 502 essence are from the sound code file by finding this use-case to be correlated with the sound code file that adds compile option, uses the coverage rate instrument to produce.This sound code file comprises sign (such as the sound code file name), statement line information and the internal process information of sound code file.Wherein, the sign of sound code file is distinguished with the sign of use-case.When specific implementation, this step 502 can be realized by script caseid_line_info.sh.
Step 503, for each relevant sound code file of this use-case, generation comprises this use-case at the statement coverage information file of the statement line sign of this sound code file covering.
This step 503 generates different statement coverage information files for the relevant different sound code files of use-case, and the sign of each statement coverage information file identifies to distinguish with use-case such as filename.This step 503 is finished by program rename_gcda.cpp program.
Step 504, the content of each statement coverage information file including that aggregation step 503 generates, generate the relevant coverage rate message file of described use-case, the coverage rate message file that described use-case is relevant comprises each relevant sound code file of this use-case and the sign of the statement line that covers at each relevant sound code file.
Step 505, the content that the coverage rate message file of being correlated with according to sign and the described use-case of described use-case comprises generates the mapping relations that comprise following content: the sign of the statement line that is covered by use-case in the sound code file that the sign of this use-case, this use-case are correlated with and this sound code file.
This step 505 can be finished by caseid_file_lines.cpp.
Can obtain the mapping relations between the sign three of the statement line that covered by use-case in the relevant sound code file of use-case sign, use-case and this sound code file by above-mentioned steps 501 to step 505.Preferably, after obtaining above-mentioned mapping relations, these mapping relations can be deposited to use-case source code mapping relations file, the sign that the sign of this document can use-case is distinguished.
Step 506 when a sound code file is modified, then records the identifying to the Codes Revised message file of the sign of the sound code file of this modification, statement line that this sound code file is modified.
This step 506 can be finished by script change_line.sh.
Step 507, for each sound code file of Codes Revised message file record, the mapping relations that comprise this key word searched in the key word that is designated of the statement line that is modified with this sound code file from above-mentioned mapping relations, if find, execution in step 508, otherwise, execution in step 509.
This step 507 can be realized by the find_modify_line_caseid.sh script.
Preferably, among the present invention, when the sign of sound code file occurs to revise, can be for each statement line in this sound code file, with the mapping relations that keyword search comprises this key word that are designated of this statement line, if find, execution in step 508, otherwise, execution in step 509.
Step 508 identifies the use-case that corresponding use-case needing to be defined as recurrence with the use-case in these mapping relations that find, and afterwards this use-case that need to return is returned.Finish current flow process.
Step 509, definite use-case that does not exist needs to return, the statement line sign that provides this generation to revise, and the suggestion that increases new use-case for the information of this statement line sign correspondence is provided.Finish current flow process.
So far, finishing method provided by the invention describes.The below is described system provided by the invention.
Referring to Fig. 6, Fig. 6 is the system construction drawing that location provided by the invention returns use-case.As shown in Figure 6, this system comprises:
The mapping relations apparatus for establishing is used for generating the mapping relations that comprise following content behind each use-case end of run: the sign of the statement line that is covered by use-case in the sound code file that the sign of this use-case, this use-case are correlated with and this sound code file;
Return use-case and determine device, it comprises searches unit and determining unit, wherein,
The described unit of searching is used for when the information of sound code file statement line occurs to revise, with the mapping relations that keyword search comprises this key word that are designated of this statement line;
Described determining unit is used for described when searching the unit and finding the mapping relations that comprise this key word, and use-case corresponding to the sign of the use-case in these mapping relations that find needing to be defined as the use-case that returns, returns the use-case that this is determined.
Preferably, described recurrence use-case determines that device further comprises:
Processing unit is used for when the sign of sound code file occurs to revise, and for each statement line in this sound code file, searches the mapping relations that comprise this key word with the described unit of searching of key word triggering that is designated of this statement line.
Among the present invention, when described determining unit does not find the mapping relations that comprise key word, further orient the statement line sign as this key word, and this statement line identifies residing sound code file, so that the user designs use-case targetedly according to statement line sign and the sound code file oriented.
Among the present invention, the mapping relations apparatus for establishing specifically can comprise with lower unit:
Record cell is used for recording the sign of this use-case behind each use-case end of run;
The sound code file generation unit is used for generating the relevant sound code file of this use-case;
Statement coverage information file generating unit is used for for each relevant sound code file of this use-case, generates to comprise this use-case at the statement coverage information file of the statement line sign of this sound code file covering;
Coverage rate message file generation unit, content for each statement coverage information file including that gathers described statement coverage information file generating unit generation, obtain the relevant coverage rate message file of described use-case, the coverage rate message file that described use-case is relevant comprises each relevant sound code file of this use-case and the sign of the statement line that covers at each relevant sound code file;
Mapping relation generating unit, content for sign and the relevant coverage rate message file of described use-case according to described use-case comprise generates the mapping relations that comprise following content: the sign of the statement line that is covered by use-case in the sound code file that the sign of this use-case, this use-case are correlated with and this sound code file.
So far, finishing system provided by the invention describes.
As can be seen from the above technical solutions, among the present invention, when the information of statement line occurs to revise in sound code file, the present invention is with the mapping relations that keyword search comprises this key word that are designated of this statement line, only use-case corresponding to the sign of the use-case in the mapping relations that find needing to be defined as the use-case of recurrence, this can fast, accurately orient the use-case that needs recurrence than prior art;
And the present invention only returns use-case corresponding to the sign of the use-case in the mapping relations that find, and all sound code file is relevant than prior art use-cases return, and this has greatly reduced use-case and has returned quantity, improves to return efficient.
Further, when determining the use-case that does not have the needs recurrence, statement line information corresponding to this statement line sign can further provide, and the residing sound code file of this statement line information, so that the tester can be according to writing targetedly use-case without the use-case sound code file, reduce testing cost, improve testing efficiency.
The above only is preferred embodiment of the present invention, and is in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of making, is equal to replacement, improvement etc., all should be included within the scope of protection of the invention.