CN117170659A - Packaging method and device for test script code - Google Patents

Packaging method and device for test script code Download PDF

Info

Publication number
CN117170659A
CN117170659A CN202310429808.0A CN202310429808A CN117170659A CN 117170659 A CN117170659 A CN 117170659A CN 202310429808 A CN202310429808 A CN 202310429808A CN 117170659 A CN117170659 A CN 117170659A
Authority
CN
China
Prior art keywords
code
target
public
test script
initial
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310429808.0A
Other languages
Chinese (zh)
Inventor
侯文龙
杨洋
陈溪
刘康婷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310429808.0A priority Critical patent/CN117170659A/en
Publication of CN117170659A publication Critical patent/CN117170659A/en
Pending legal-status Critical Current

Links

Abstract

The disclosure provides a packaging method of test script codes, relates to the field of software testing, and can be applied to the technical field of finance. The method comprises the following steps: responding to the packaging instruction of the test script code, and carrying out first similarity analysis on the test script source code to determine an initial public code section; performing cluster analysis on the initial public code segments to generate a plurality of public code clusters; forming a common code segment set by using initial common code segments, the called times of which are larger than a first preset threshold value, in the common code clusters; performing public script encapsulation based on the public code segment set to determine a target public code segment; and secondarily packaging the target public code segment according to a preset packaging rule to generate a target public code block. The present disclosure also provides a packaging apparatus, device, storage medium and program product of test script code.

Description

Packaging method and device for test script code
Technical Field
The present disclosure relates to the field of automated testing technologies, and in particular, to the field of page testing technologies, and more particularly, to a method, apparatus, device, storage medium, and program product for packaging test script codes.
Background
In the process of automatic test script writing at the UI end, in order to improve working efficiency, testers usually adopt some automatic test tools with script recording functions to carry out automatic script writing, when the testers begin to write scripts, the automatic test tools record that the testers finish operation in a browser, the test tools automatically form corresponding automatic test scripts, and compared with a manual line-by-line writing mode, the automatic test script writing efficiency can be greatly improved by using the mode.
In the related technology, along with the mass accumulation of the automatic test script assets, part of enterprises introduce intelligent analysis modes of similarity analysis of public code fragments, and the public code fragments with high occurrence frequency are uniformly packaged by automatically extracting public modules for subsequent automatic script asset management and new script programming.
However, in the mode of only adopting the similarity analysis of the code segments, the situation that part of basic flows are packaged into common modules and different subdivision scenes are packaged into other common modules can occur, so that the subdivided scene flows are packaged into two common code modules, when a certain subdivision flow also changes due to the change of the customized reconstruction basic flow, the two previously packaged common code modules cannot be adapted, the automatic packaging method of the common modules is effective, and the situation that test personnel manually re-write the scripts is required.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a method, apparatus, device, medium, and program product for packaging test script code that improves the efficiency of automated testing efforts.
According to a first aspect of the present disclosure, there is provided a method of packaging test script code, the method comprising:
responding to the packaging instruction of the test script code, and carrying out first similarity analysis on the test script source code to determine an initial public code section;
performing cluster analysis on the initial public code segments to generate a plurality of public code clusters;
forming a common code segment set by using initial common code segments, the called times of which are larger than a first preset threshold value, in the common code clusters;
performing public script encapsulation based on the public code segment set to determine a target public code segment; and
and secondarily packaging the target public code segment according to a preset packaging rule to generate a target public code block.
According to an embodiment of the disclosure, the performing cluster analysis on the initial common code segment to generate a plurality of common code clusters includes:
and performing second similarity analysis on the initial common code segments to generate a plurality of common code clusters.
According to an embodiment of the present disclosure, the performing a second similarity analysis on the initial common code segment to generate a plurality of common code clusters includes:
taking any initial public code segment as a class, and calculating the similarity between other initial public code segments and any initial public code segment;
combining the initial public code segments with the similarity larger than a second preset threshold value to form a new classification; and
and carrying out multi-round clustering until the similarity between the current initial common code segments is smaller than a second preset threshold value.
According to an embodiment of the disclosure, the forming the initial common code segment with the number of times of being called in the common code cluster being greater than a first preset threshold value into a common code segment set includes:
counting the called times of initial public code segments in the public code clusters; and
and sequencing the initial common code segments with the called times larger than a first preset threshold value to generate a common code segment set.
According to an embodiment of the disclosure, the performing public script encapsulation based on the public code segment set to determine the target public code segment includes:
determining the same code segment and different code segments in the common code segment set through text content comparison;
combining the same code segments; and
and carrying out branch judgment processing on the different code segments.
According to an embodiment of the present disclosure, the performing secondary encapsulation on the target common code segment according to a preset encapsulation rule to generate a target common code block includes:
determining a target encapsulation rule according to the type of the operation object in the target public code section; and
and encapsulating the target public code segment according to the target encapsulation rule to generate a target public code block.
According to an embodiment of the disclosure, the determining a target encapsulation rule according to an operation object type in the common code includes:
if the operation object type is determined to be the browser connection operation, determining the target encapsulation rule to be the operation of adding waiting and window maximization after the browser connection operation is acquired;
if the operation object type is determined to be the click operation, determining the target encapsulation rule to be to increase the waiting time after the click operation; and
And if the operation object type is determined to be the input operation, determining the target encapsulation rule to be a click operation added with the same element before the input operation.
According to an embodiment of the present disclosure, after generating the target common code block, further includes:
verifying the validity of the target public code block; and
and generating a public code block management list according to the validity verification result.
According to an embodiment of the disclosure, the verifying the validity of the target common code block includes:
replacing the corresponding public code segments in the test script with the target public code blocks to generate a target test script;
executing the target test script to obtain the execution success rate of the target test script;
when the execution success rate is greater than or equal to a third preset threshold value, determining that the target public code block is valid; and
and when the execution success rate is determined to be smaller than a third preset threshold value, determining that the target public code block is invalid.
According to an embodiment of the present disclosure, the performing a first similarity analysis on the test script source code to determine an initial common code segment includes:
preprocessing the test script source code to generate target test script code information;
Performing word frequency analysis on the target test script code information by using a text keyword extraction algorithm to generate a word frequency analysis result; and
and determining codes with word frequency larger than a fourth preset threshold value in the target test script code information as initial public code segments.
According to an embodiment of the present disclosure, the preprocessing the test script source code to generate target test script code information includes:
scanning a test script source code to identify a test page operation object in the test script source code;
determining operation action information and processing method information of the test page operation object according to the test page operation object;
performing hash operation on the test page operation object to generate a hash value; and
and generating target test script code information according to the test page operation object information, the operation action information, the processing method information and the hash value.
According to an embodiment of the present disclosure, the performing word frequency analysis on the target test script code information using a text keyword extraction algorithm to generate a word frequency analysis result includes:
extracting the target test script codes according to a script execution sequence according to a preset step length to generate first target codes;
Calculating word frequency information of the first target code; and
and generating a word frequency analysis result according to the word frequency information.
A second aspect of the present disclosure provides a packaging apparatus for testing script code, the apparatus comprising:
the initial public code segment determining module is used for responding to the packaging instruction of the test script code and carrying out first similarity analysis on the test script source code so as to determine an initial public code segment;
the cluster analysis module is used for carrying out cluster analysis on the initial public code segments so as to generate a plurality of public code clusters;
the public code segment set generation module is used for forming a public code segment set from initial public code segments, of which the called times are larger than a first preset threshold, in the public code clusters;
the target public code segment determining module is used for carrying out public script encapsulation based on the public code segment set so as to determine target public code segments; and
and the target public code block generation module is used for encapsulating the target public code segments according to preset encapsulation rules to generate target public code blocks.
According to an embodiment of the disclosure, the cluster analysis module includes a cluster analysis sub-module;
And the cluster analysis sub-module is used for carrying out second similarity analysis on the initial public code segments so as to generate a plurality of public code clusters.
According to an embodiment of the present disclosure, the cluster analysis submodule includes: the device comprises a similarity calculation unit, a merging unit and a clustering unit.
The similarity calculation unit is used for taking any public code segment as a class and calculating the similarity between other public code segments and any public code segment;
the merging unit is used for merging the public code segments with the similarity larger than a second preset threshold value to form a new classification; and
and the clustering unit is used for carrying out multi-round clustering until the similarity between the current public code segments is smaller than a second preset threshold value.
According to an embodiment of the disclosure, the common code segment set generation module includes a statistics sub-module and a common code segment set generation sub-module.
The statistics sub-module is used for counting the called times of the initial public code segments in the public code clusters; and
and the public code fragment set generation sub-module is used for sequencing the initial public code fragments with the called times larger than a first preset threshold value so as to generate a public code fragment set.
According to an embodiment of the present disclosure, the target common code segment determination module includes: the system comprises a comparison sub-module, a merging sub-module and a branch judgment processing sub-module.
The comparison sub-module is used for determining the same code segment and different code segments in the public code segment set through text content comparison;
the merging submodule is used for merging the same code fragments; and
and the branch judgment processing sub-module is used for carrying out branch judgment processing on the different code segments.
According to an embodiment of the present disclosure, an object common code block generation module includes: the first determination sub-module and the target common code block generation sub-module.
A first determining submodule, configured to determine a target encapsulation rule according to an operation object type in the target common code segment; and
and the target public code block generation sub-module is used for packaging the target public code segments according to the target packaging rule so as to generate target public code blocks.
According to an embodiment of the present disclosure, the first determination submodule includes a first determination unit, a second determination unit, and a third determination unit.
The first determining unit is used for determining that the target encapsulation rule is to increase waiting and window maximizing operations after the browser connection operation is acquired if the operation object type is determined to be the browser connection operation;
The second determining unit is used for determining that the target encapsulation rule is to increase the waiting time after the clicking operation if the operation object type is determined to be the clicking operation; and
and the third determining unit is used for determining the target encapsulation rule as a click operation added with the same element before the input operation if the operation object type is determined to be the input operation.
According to an embodiment of the present disclosure, further comprising: the system comprises a verification module and a public code block management list generation module.
The verification module is used for verifying the validity of the target public code block; and
and the public code block management list generation module is used for generating a public code block management list according to the validity verification result.
According to an embodiment of the present disclosure, the common code block management manifest generation module includes: the target test script generation sub-module, the acquisition sub-module, the second determination sub-module and the third determination sub-module.
The target test script generation sub-module is used for replacing the corresponding public code segments in the test script with the target public code blocks so as to generate a target test script;
the acquisition sub-module is used for executing the target test script to acquire the execution success rate of the target test script;
A second determining submodule, configured to determine that the target common code block is valid when it is determined that the execution success rate is greater than or equal to a third preset threshold; and
and the third determining submodule is used for determining that the target public code block is invalid when the execution success rate is smaller than a third preset threshold value.
According to an embodiment of the present disclosure, the initial common code segment determination module includes: the system comprises a preprocessing sub-module, a word frequency analysis sub-module and a fourth determination sub-module.
The preprocessing sub-module is used for preprocessing the test script source code to generate target test script code information;
the word frequency analysis sub-module is used for performing word frequency analysis on the target test script code information by using a text keyword extraction algorithm so as to generate a word frequency analysis result; and
and the fourth determining submodule is used for determining that codes with word frequency larger than a fourth preset threshold value in the target test script code information are initial public code segments.
According to an embodiment of the present disclosure, the preprocessing submodule includes: the device comprises a scanning unit, a fourth determining unit, a hash value calculating unit and a target test script code information generating unit.
The scanning unit is used for scanning the test script source code to identify a test page operation object in the test script source code;
A fourth determining unit, configured to determine operation action information and processing method information of the test page operation object according to the test page operation object;
the hash value calculation unit is used for carrying out hash operation on the test page operation object so as to generate a hash value; and
and the target test script code information generating unit is used for generating target test script code information according to the test page operation object information, the operation action information, the processing method information and the hash value.
According to an embodiment of the present disclosure, a word frequency analysis submodule includes: the system comprises a first target code generation sub-module, a calculation sub-module and a word frequency analysis result generation sub-module.
The first target code generation sub-module is used for extracting the target test script codes according to a script execution sequence according to a preset step length so as to generate first target codes;
a computing sub-module for computing word frequency information of the first object code; and
and the word frequency analysis result generation sub-module is used for generating a word frequency analysis result according to the word frequency information.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of packaging test script code described above.
A fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method of packaging test script code described above.
A fifth aspect of the present disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the method of encapsulating test script code described above.
According to the method for encapsulating the test script code, after the initial public code segments are determined, cluster analysis is conducted on the initial public code segments to obtain a plurality of public code clusters, the called times of the initial public code segments in each public code cluster are counted, the initial public code segments with the called times larger than the first preset threshold value in the public code clusters are formed into a public code segment set, the public code segment set is encapsulated, the target public code segments are determined, the target public code segments are encapsulated for the second time according to preset encapsulation rules, so that target public code blocks are generated, the encapsulation integrity of the public code modules is improved, the script quantity of the public code blocks is reduced, and insurance maintenance of the public code blocks is facilitated.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be more apparent from the following description of embodiments of the disclosure with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates application scenario diagrams of test script code packaging methods, apparatus, devices, media and program products according to embodiments of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a method of packaging test script code provided in accordance with an embodiment of the present disclosure;
FIG. 3a schematically illustrates one of the flowcharts of one method of determining an initial common code segment provided in accordance with embodiments of the present disclosure;
FIG. 3b schematically illustrates a second flowchart of a method of determining an initial common code segment provided in accordance with an embodiment of the present disclosure;
FIG. 3c schematically illustrates a third flowchart of a method of determining an initial common code segment provided in accordance with an embodiment of the present disclosure;
FIG. 4a schematically illustrates one of the flowcharts of one common code cluster analysis method provided in accordance with an embodiment of the disclosure;
FIG. 4b schematically illustrates a second flowchart of a common code cluster analysis method provided in accordance with an embodiment of the disclosure;
FIG. 5 schematically illustrates a flow chart of a common code segment set generation method provided in accordance with an embodiment of the present disclosure;
FIG. 6 schematically illustrates a flow chart of a method of determining target common code segments provided in accordance with an embodiment of the present disclosure;
FIG. 7a schematically illustrates one of the flowcharts of a method of encapsulating a target common code block provided in accordance with an embodiment of the present disclosure;
FIG. 7b schematically illustrates a second flowchart of a method of encapsulating a target common code block provided in accordance with an embodiment of the present disclosure;
FIG. 8a schematically illustrates one of the flowcharts of the target common code block verification method provided in accordance with an embodiment of the present disclosure;
FIG. 8b schematically illustrates a second flowchart of a target common code block verification method provided in accordance with an embodiment of the present disclosure;
FIG. 9 schematically illustrates a block diagram of a package of test script code, according to an embodiment of the disclosure; and
fig. 10 schematically illustrates a block diagram of an electronic device adapted to implement a method of encapsulation of test script code, in accordance with an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is only exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and/or the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where expressions like at least one of "A, B and C, etc. are used, the expressions should generally be interpreted in accordance with the meaning as commonly understood by those skilled in the art (e.g.," a system having at least one of A, B and C "shall include, but not be limited to, a system having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
Based on the technical problems described above, an embodiment of the present disclosure provides a method for packaging test script codes, the method including: responding to the packaging instruction of the test script code, and carrying out first similarity analysis on the test script source code to determine an initial public code section; performing cluster analysis on the initial public code segments to generate a plurality of public code clusters; forming a common code segment set by using initial common code segments, the called times of which are larger than a first preset threshold value, in the common code clusters; performing public script encapsulation based on the public code segment set to determine a target public code segment; and secondarily packaging the target public code segment according to a preset packaging rule to generate a target public code block.
Fig. 1 schematically illustrates an application scenario diagram of a method, apparatus, device, medium, and program product for packaging test script code according to an embodiment of the present disclosure.
As shown in fig. 1, an application scenario 100 according to this embodiment may include a page test script automation test scenario. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Various communication client applications, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only) may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 105 may be a page test script management server, which pre-processes the stock test script codes, extracts a common code portion by word frequency analysis, performs cluster analysis on the common codes, merges common codes of the same type and encapsulates the common codes according to preset encapsulation rules to generate a common code block, for example, in response to an encapsulation instruction of the test script codes sent by the user through the application server.
It should be noted that, the method for packaging test script codes provided in the embodiments of the present disclosure may be generally executed by the server 105. Accordingly, the encapsulation means of the test script code provided by the embodiments of the present disclosure may be generally provided in the server 105. The encapsulation method of the test script code provided by the embodiments of the present disclosure may also be performed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the encapsulation means of the test script code provided by the embodiments of the present disclosure may also be provided in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
It should be noted that, the method and the device for packaging the test script code determined by the embodiments of the present disclosure may be used in the field of automated testing technology, may also be used in the field of financial technology, and may also be used in any field other than the financial field.
The following will describe in detail a method of packaging test script codes of the embodiment of the present disclosure by fig. 2 to 8 based on the scenario described in fig. 1.
Fig. 2 schematically illustrates a flowchart of a method of packaging test script code provided in accordance with an embodiment of the present disclosure. As shown in fig. 2, the method for packaging test script code of this embodiment includes operations S210 to S250, which can be performed by an automated test script code module intelligent packaging apparatus.
In operation S210, a first similarity analysis is performed on the test script source code in response to the package instruction of the test script code to determine an initial common code segment.
In one example, there are a large number of duplicate code segments in an automation test script corresponding to a business scenario of similar function or transaction type; in addition, due to development habits of different test developers, codes of the same function are not completely consistent, and when corresponding functions in the repeated code segments are changed, all relevant automatic test scripts need to be adjusted, so that a large amount of repeated redundant workload is generated. In order to reduce a large number of redundant codes existing in test script source codes, similarity analysis is carried out on the source codes, similar code fragments are used as common code fragments for encapsulation, when a certain system function is changed, and corresponding automatic test script codes are subjected to fresh-keeping maintenance, the fresh-keeping maintenance cost of test developers on the stored automatic test scripts is greatly reduced, the working cost of modularized encapsulation is carried out on high-frequency use common modules, the efficiency of automatic test work is improved, and the resource investment is reduced. The specific similarity analysis process can refer to the operation steps shown in fig. 3a to 3c, and will not be described herein.
In operation S220, a cluster analysis is performed on the initial common code segments to generate a plurality of common code clusters.
In operation S230, an initial common code segment in the common code cluster, which is called for times greater than a first preset threshold, is formed into a common code segment set.
In operation S240, a public script package is performed based on the set of public code segments to determine a target public code segment.
In one example, in a financial service, script codes with the same function may be encapsulated into a plurality of initial public code segments due to different subdivided service scenarios, for example, purchase flows of different financial products, medium types need to be selected when the "add treasures" products are purchased, branches and fund accounts need to be selected for the "all Xin equity" products and the "Xin Equiz" products, and the whole purchase flows are the same except that the differences are that the purchase flows need to be input for purchase amount, product specification reading and U shield signature checking. When the U-shields are used for enterprise network login, interface styles popped up by the U-shields of different manufacturers are different, and scripts are encapsulated into different public code modules. In order to reduce the number of the public code blocks and facilitate the preservation and maintenance of the later period, the initial public code segments obtained in operation S210 are subjected to cluster analysis, and the code segments with different service types and the same or similar actual functions are combined into the same public code cluster, wherein the public code cluster generation process can refer to the operation steps shown in fig. 4a and fig. 4 b.
In one example, after generating a plurality of public code clusters, performing secondary analysis on each public code cluster, specifically determining the number of times of calling each initial public code segment in each public code cluster, and if the number of times of calling is less than or equal to a first preset threshold value, determining that the public code segment is less used and does not need to perform public script encapsulation. If the number of times of being called is greater than the first preset threshold, it is determined that the usage frequency of the common code segment is high, and a common script encapsulation is required to improve the quality of the common code block, and the initial common code segment with the number of times of being called in the common code cluster greater than the first preset threshold is formed into a common code segment set, and a specific process can refer to operation S231 and operation S232 shown in fig. 5.
After the common code segment set is formed, the common script package is performed based on the common code segment set, and the common code segments are combined to form a new common code segment, namely, a target common code segment, and the specific process can be seen from operation 241 to operation S243 shown in fig. 6.
In operation S250, the target common code segment is secondarily encapsulated according to a preset encapsulation rule to generate a target common code block.
In one example, in order to improve the execution success rate of the modularization of the public code, after determining the target public code segment, the code information existing in the target public code segment finally obtained in operation S240 is packaged according to a preset packaging rule by an intelligent method, and the modularization packaging of the inventory automation test script is completed by a mode of calling the public code, and specific packaging rules and packaging processes can refer to the operation steps shown in fig. 7a to 7b, which are not repeated here.
According to the method for encapsulating the test script code, after the initial public code segments are determined, cluster analysis is conducted on the initial public code segments to obtain a plurality of public code clusters, the called times of the initial public code segments in each public code cluster are counted, the initial public code segments with the called times larger than the first preset threshold value in the public code clusters are formed into a public code segment set, the public code segment set is encapsulated, the target public code segments are determined, the target public code segments are encapsulated for the second time according to preset encapsulation rules, so that target public code blocks are generated, the encapsulation integrity of the public code modules is improved, the script quantity of the public code blocks is reduced, and insurance maintenance of the public code blocks is facilitated.
Fig. 3a schematically illustrates one of flowcharts of a method for determining an initial common code segment provided according to an embodiment of the present disclosure, fig. 3b schematically illustrates the second of the flowcharts of the method for determining an initial common code segment provided according to an embodiment of the present disclosure, and fig. 3c schematically illustrates the third of the flowcharts of the method for determining an initial common code segment provided according to an embodiment of the present disclosure.
As shown in fig. 3a, operation S210 includes operations S211 to S213.
In operation S211, the test script source code is preprocessed to generate target test script code information.
As shown in fig. 3b, operation S211 includes operations S2111 to S2114.
In operation S2111, the test script source code is scanned to identify a test page operation object in the test script source code.
In operation S2112, operation action information and processing method information of the test page operation object are determined according to the test page operation object.
In operation S2113, a hash operation is performed on the test page operation object to generate a hash value.
In operation S2114, target test script code information is generated from the test page operation object information, the operation action information, the processing method information, and the hash value.
In one example, a test page operation object in the test script code is scanned, the test page operation object includes a control element in a page, for example, the control element may be an input box, a click button, or the like, and operation action information and processing method information corresponding to each test page operation object are determined according to the type of the test page operation object and the test script code, where the processing method information includes a judgment loop statement, for example, an ifelseif condition judgment statement. In order to facilitate the analysis and statistics of the word frequency in the later stage, hash operation is needed to be performed on the test page operation objects to obtain hash values, that is, the hash values of the same test page operation object are the same, and target test script code information is generated according to the test page operation object information, the operation action information, the processing method information and the hash values, as shown in table 1 below.
TABLE 1 target test script code information table
In operation S212, word frequency analysis is performed on the target test script code information using a text keyword extraction algorithm to generate a word frequency analysis result.
In operation S213, it is determined that the code with the word frequency greater than the fourth preset threshold value in the target test script code information is the initial common code segment.
As shown in fig. 3c, operation S212 includes operations S2121 to S2123.
In operation S2121, the target test script code is extracted according to a script execution sequence according to a preset step size to generate a first target code.
In operation S2122, word frequency information of the first object code is calculated.
In operation S2123, a word frequency analysis result is generated from the word frequency information.
In one example, the pre-processed automated test scripts are subjected to similarity analysis, the common code blocks are extracted and packaged by using a text keyword extraction algorithm, the packaged code blocks are submitted to a common code definition module for storage processing, the state is set to be verified, and the corresponding relationship is recorded. The text keyword extraction algorithm is used for processing the noise-reduced codes and extracting script contents in a mode of positive +word frequency +step length. The forward direction means that extraction is required according to the execution sequence of the script, the preset step length can be, for example, 6 lines of codes are extracted according to the execution sequence of the script to be used as a first target code, the frequency of the first target code in the script is calculated, word frequency information is obtained, the word frequency information is analyzed, and codes with the word frequency reaching a certain condition can be used as public codes to be packaged.
Fig. 4a schematically illustrates one of flowcharts of a common code cluster analysis method provided according to an embodiment of the present disclosure, and fig. 4b schematically illustrates the second of flowcharts of a common code cluster analysis method provided according to an embodiment of the present disclosure.
As shown in fig. 4a, operation S220 includes operation S221.
In operation S221, a second similarity analysis is performed on the initial common code segment to generate a plurality of common code clusters.
As shown in fig. 4b, operation S221 includes operations S2211 to S2213.
In operation S2211, the similarity between other common code segments and any common code segment is calculated using any common code segment as a class.
In operation S2212, the common code segments with the similarity greater than the second preset threshold are combined to form a new classification.
In operation S2213, multiple rounds of clustering are performed until the similarity between the current common code segments is less than a second preset threshold.
In one example, a clustering algorithm is employed to perform a clustering analysis, i.e., a similarity analysis, on the initial common code segments. Taking HAC (Hierarchy) hierarchical aggregation clustering algorithm as an example, any one initial public code segment is selected as a single class, the similarity between other initial public code segments and the initial public code segment is calculated, the initial public code segments with the similarity larger than a second preset threshold value are combined to form a new class, the second preset threshold value can be 80%, the steps are continuously repeated, one initial public code segment is selected from the rest initial public code segments as the single class, the similarity is calculated for carrying out multi-round clustering until no initial public code segment with the similarity larger than the second preset threshold value exists under the current class, and cluster analysis is terminated to obtain different public code cluster groups A/B/C/D.
Fig. 5 schematically illustrates a flowchart of a method for generating a set of common code segments, provided according to an embodiment of the present disclosure. As shown in fig. 5, operation S230 includes operation S231 and operation S232.
In operation S231, the number of times the initial common code segment is called in the common code cluster is counted.
In operation S232, the initial common code segments with the called times greater than the first preset threshold are ordered to generate a common code segment set.
In one example, the initial common code segments in each common code cluster have 80% similarity, but each common code segment is called differently in the script. And (3) carrying out quantity sequencing on different clustering groups, counting the called times of initial public code segments in the public code clusters, and determining a public code segment set with the reference number of the automated script being larger than a first preset threshold, wherein the first preset threshold can be 5 times, for example, to form A1\B1\C1\D1. Based on the called times of the A1\B1\C1\D1 public code fragments, the new ordered sets A11, A12, A13 and A14 in the group are formed by sorting from large to small.
Fig. 6 schematically illustrates a flow chart of a method for determining target common code segments provided in accordance with an embodiment of the present disclosure. As shown in fig. 6, operation S240 includes operations 241 to 243.
In operation S241, the same code segments and different code segments in the common code segment set are determined through text content comparison.
In operation S242, the same code segment is subjected to a merging process.
In operation S243, a branch judgment process is performed on the different code segments.
In one example, taking a public code segment set a11, a12, a13 and a14 as an example, packaging public scripts based on the a11, a12, a13 and a14 again, firstly comparing text contents to obtain the same segment and different segments in the a11, a12, a13 and a14, combining the same segment, and branching different segments to finally form a new public code module a'. The process in A' can simultaneously meet the processing flows in the scripts of A11, A12, A13 and A14. For example, four initial public code segments A11, A12, A13 and A14 are shared in a script of a U-shield login enterprise network, the operation before the U-shield password frame is activated is determined to be consistent through text comparison analysis, the operation of inputting passwords is also consistent, and the steps of activating, clicking the U-shield password frame and clicking a determination button are carried out on different points, so that codes corresponding to the same operation are combined, and branch judgment processing is carried out on different code segments.
Fig. 7a schematically illustrates one of the flowcharts of a method of encapsulating a target common code block provided according to an embodiment of the present disclosure. Fig. 7b schematically illustrates a second flowchart of a method of encapsulating a target common code block provided in accordance with an embodiment of the present disclosure. As shown in fig. 7a, operation S250 includes operations S251 to S252.
In operation S251, a target encapsulation rule is determined according to the type of the operation object in the target common code segment.
In operation S252, the target common code segment is encapsulated according to the target encapsulation rule to generate a target common code block.
As shown in fig. 7b, operation S251 includes operations S2511 to S2513.
In operation S2511, if it is determined that the operation object type is the get browser connection operation, the target encapsulation rule is determined to add a wait and window maximization operation after the get browser connection operation.
In operation S2512, if it is determined that the operation object type is a click operation, the target encapsulation rule is determined to increase the waiting time after the click operation.
In operation S2513, if it is determined that the operation object type is an input operation, it is determined that the target encapsulation rule is a click operation to add the same element before the input operation.
In one example, when the word frequency of the first object code corresponding to any operation object reaches a preset threshold value of the total number of the current scripts, for example, 5% of the total number of the scripts, the first object code is packaged, so that in order to improve the success rate of executing the packaged public code, smooth execution of the test scripts is ensured, and the package is required to be performed by using a preset package rule. The specific rules are as follows:
(1) After the browser connection operation (driver. Get) is acquired, a waiting and window maximizing operation (driver. Message (). Window (). Maximum ()) is added. Simulating page opening operation, increasing waiting time to wait for page loading, and increasing window maximizing operation after page loading.
(2) The wait time is increased after the click operation (click). In order to shield the influence of the network difference on the page test, waiting time is increased after clicking operation is performed, and the server response is waited.
(3) The click operation of the same element is added before the input operation (sendKeys). In order to ensure that information can be successfully input in the input box, clicking operation of the same element is added before the input operation, and the current input box is ensured to be in an activated state.
(4) And adding a screen capturing operation after the if condition judgment is finished.
And determining corresponding encapsulation rules according to different operation object types, and encapsulating to generate a target public block. After the target common code block is generated, validity of the common code block needs to be verified.
Fig. 8a schematically illustrates one of the flowcharts of the target common code block verification method provided according to an embodiment of the present disclosure. Fig. 8b schematically illustrates a second flowchart of a target common code block verification method provided according to an embodiment of the present disclosure, as shown in fig. 8a, including operations S310 and S320.
In operation S310, validity of the target common code block is verified.
As shown in fig. 8b, operation S310 includes operations S311 to S314.
In operation S311, the target common code block is substituted for the corresponding common code segment in the test script to generate a target test script.
In operation S312, the target test script is executed to obtain an execution success rate of the target test script.
In operation S313, when it is determined that the execution success rate is equal to or greater than a third preset threshold, it is determined that the target common code block is valid.
In operation S314, when it is determined that the execution success rate is less than a third preset threshold, it is determined that the target common code block is invalid.
In one example, the common code block validity verification rule is as follows:
(1) If 80% of the automated test scripts pass the execution, the packaging is proved to be successful, the corresponding public code state in the public code block definition module is set to pass the verification, and the version of the corresponding content of the executed automated test scripts after the modular packaging is updated to the asset library of the automated test scripts.
(2) If 80% of the code blocks are not passed, readjusting the code public segments, and putting the code segments which are not passed into a code feature library which is not passed, and when corresponding code blocks appear in the subsequent comparison process, not carrying out secondary packaging processing. While rollback the script to the last version.
In operation S320, a common code block management manifest is generated according to the validity verification result.
In one example, to avoid repeated extraction of the verification and improve the generation efficiency of the common code blocks, the verification result is generated into a common code block management list, which is shown in table 2 in detail. Recording the state of a public code block used for storing the packaged public code block, and comparing the public code block with a corresponding list of an automatic test script which is referenced to the code block, wherein the public code block is defined with two sources: the device automatically and intelligently packages the public module and manually packages the public module by testers. The public module manually packaged by the tester is mainly used for the known parts which are not suitable for being packaged according to the models, and for the public codes which cannot be packaged, the corresponding information can be directly perfected into the public code block definition module, so that the resource waste caused by repeated screening is avoided.
Table 2 common code block management checklist
/>
According to the method for packaging the test script codes, provided by the embodiment of the disclosure, the code blocks in the original automatic test script are intelligently adjusted to be in a common module reference mode, so that the structure of the automatic test script is simplified, and the common code block asset is intelligently formed; meanwhile, intelligent analysis can be carried out on invalid operations such as misoperation clicking or repeated clicking and the like in the script, invalid misoperation is automatically removed, and original invalid operation script sentences are deleted from the packaged code fragments. And then, the packaging is automatically carried out, so that the structure of an automatic test script is greatly simplified, the invalid redundant code quantity is reduced, and the packaging quality and the execution efficiency of the public module of the automatic script are provided.
Based on the above test script code packaging method, the present disclosure also provides a test script code packaging device. The device will be described in detail below in connection with fig. 9.
Fig. 9 schematically illustrates a block diagram of a package apparatus for testing script code according to an embodiment of the present disclosure.
As shown in fig. 9, the encapsulation apparatus 900 of the test script code of this embodiment includes an initial common code segment determination module 910, a cluster analysis module 920, a common code segment set generation module 930, a target common code segment determination module 940, and a target common code block generation module 950.
The initial common code segment determination module 910 is configured to perform a first similarity analysis on the test script source code in response to the package instruction of the test script code to determine an initial common code segment. In an embodiment, the initial common code segment determining module 910 may be configured to perform the operation S210 described above, which is not described herein.
The cluster analysis module 920 is configured to perform cluster analysis on the initial common code segment to generate a plurality of common code clusters. In an embodiment, the cluster analysis module 920 may be used to perform the operation S220 described above, which is not described herein.
The common code segment set generating module 930 is configured to form a common code segment set from initial common code segments in the common code cluster, where the number of times of the initial common code segments is greater than a first preset threshold. In an embodiment, the common code segment set generating module 930 may be configured to perform the operation S230 described above, which is not described herein.
The target public code segment determination module 940 is configured to perform public script encapsulation based on the public code segment set to determine a target public code segment. In an embodiment, the target common code segment determining module 940 may be configured to perform the operation S240 described above, which is not described herein.
The target common code block generating module 950 is configured to encapsulate the target common code segment according to a preset encapsulation rule, so as to generate a target common code block. In an embodiment, the target common code block generating module 950 may be configured to perform the operation S250 described above, which is not described herein.
According to an embodiment of the disclosure, the cluster analysis module includes a cluster analysis sub-module;
and the cluster analysis sub-module is used for carrying out second similarity analysis on the initial public code segments so as to generate a plurality of public code clusters. In an embodiment, the cluster analysis sub-module may be used to perform the operation S221 described above, which is not described herein.
According to an embodiment of the present disclosure, the cluster analysis submodule includes: the device comprises a similarity calculation unit, a merging unit and a clustering unit.
And the similarity calculation unit is used for taking any public code segment as a class and calculating the similarity between other public code segments and any public code segment. In an embodiment, the similarity calculation unit may be used to perform the operation S2211 described above, which is not described herein.
And the merging unit is used for merging the public code segments with the similarity larger than a second preset threshold value to form a new classification. In an embodiment, the synthesizing unit may be configured to perform the operation S2212 described above, which is not described herein.
And the clustering unit is used for carrying out multi-round clustering until the similarity between the current public code segments is smaller than a second preset threshold value. In an embodiment, the clustering unit may be configured to perform the operation S2213 described above, which is not described herein.
According to an embodiment of the disclosure, the common code segment set generation module includes a statistics sub-module and a common code segment set generation sub-module.
And the statistics sub-module is used for counting the called times of the initial public code segments in the public code clusters. In an embodiment, the statistics sub-module may be used to perform the operation S231 described above, which is not described herein.
And the public code fragment set generation sub-module is used for sequencing the initial public code fragments with the called times larger than a first preset threshold value so as to generate a public code fragment set. In an embodiment, the common code segment set generating sub-module may be used to perform the operation S232 described above, which is not described herein.
According to an embodiment of the present disclosure, the target common code segment determination module includes: the system comprises a comparison sub-module, a merging sub-module and a branch judgment processing sub-module.
And the comparison sub-module is used for determining the same code segment and different code segments in the common code segment set through text content comparison. In an embodiment, the alignment sub-module may be used to perform the operation S241 described above, which is not described herein.
And the merging sub-module is used for merging the same code fragments. In an embodiment, the merging sub-module may be used to perform the operation S242 described above, which is not described herein.
And the branch judgment processing sub-module is used for carrying out branch judgment processing on the different code segments. In an embodiment, the branch determination processing sub-module may be configured to perform the operation S243 described above, which is not described herein.
According to an embodiment of the present disclosure, an object common code block generation module includes: the first determination sub-module and the target common code block generation sub-module.
And the first determining submodule is used for determining a target encapsulation rule according to the type of the operation object in the target public code segment. In an embodiment, the first determining sub-module may be used to perform the operation S251 described above, which is not described herein.
And the target public code block generation sub-module is used for packaging the target public code segments according to the target packaging rule so as to generate target public code blocks. In an embodiment, the target common code block generating sub-module may be used to perform the operation S252 described above, which is not described herein.
According to an embodiment of the present disclosure, the first determination submodule includes a first determination unit, a second determination unit, and a third determination unit.
And the first determining unit is used for determining that the target encapsulation rule is to add waiting and window maximizing operations after the browser connection operation is acquired if the operation object type is determined to be the browser connection operation. In an embodiment, the first determining unit may be configured to perform the operation S2511 described above, which is not described herein.
And the second determining unit is used for determining that the target encapsulation rule is to increase the waiting time after the clicking operation if the operation object type is determined to be the clicking operation. In an embodiment, the second determining unit may be configured to perform the operation S2512 described above, which is not described herein.
And the third determining unit is used for determining the target encapsulation rule as a click operation added with the same element before the input operation if the operation object type is determined to be the input operation. In an embodiment, the third determining unit may be configured to perform the operation S2513 described above, which is not described herein.
According to an embodiment of the present disclosure, further comprising: the system comprises a verification module and a public code block management list generation module.
And the verification module is used for verifying the validity of the target public code block. In an embodiment, the verification module may be configured to perform the operation S310 described above, which is not described herein.
And the public code block management list generation module is used for generating a public code block management list according to the validity verification result. In an embodiment, the common code block management manifest generating module may be configured to perform the operation S320 described above, which is not described herein.
According to an embodiment of the present disclosure, the common code block management manifest generation module includes: the target test script generation sub-module, the acquisition sub-module, the second determination sub-module and the third determination sub-module.
And the target test script generation sub-module is used for replacing the corresponding public code segments in the test script with the target public code blocks so as to generate the target test script. In an embodiment, the common code block management manifest generating module may be configured to perform the operation S320 described above, which is not described herein.
And the acquisition sub-module is used for executing the target test script to acquire the execution success rate of the target test script. In an embodiment, the obtaining sub-module may be used to perform the operation S321 described above, which is not described herein.
And the second determining submodule is used for determining that the target public code block is valid when the execution success rate is greater than or equal to a preset threshold value. In an embodiment, the second determining sub-module may be used to perform the operation S322 described above, which is not described herein.
And the third determining submodule is used for determining that the target public code block is invalid when the execution success rate is smaller than a preset threshold value. In an embodiment, the third determining sub-module may be used to perform the operation S323 described above, which is not described herein.
According to an embodiment of the present disclosure, the initial common code segment determination module includes: the system comprises a preprocessing sub-module, a word frequency analysis sub-module and a fourth determination sub-module.
And the preprocessing sub-module is used for preprocessing the test script source code to generate target test script code information. In an embodiment, the preprocessing sub-module may be used to perform the operation S211 described above, which is not described herein.
And the word frequency analysis sub-module is used for carrying out word frequency analysis on the target test script code information by using a text keyword extraction algorithm so as to generate a word frequency analysis result. In an embodiment, the word frequency analysis sub-module may be used to perform the operation S212 described above, which is not described herein.
And the fourth determination submodule is used for determining that codes with word frequency larger than a preset threshold value in the target test script code information are initial public code segments. In an embodiment, the fourth determining sub-module may be used to perform the operation S213 described above, which is not described herein.
According to an embodiment of the present disclosure, the preprocessing submodule includes: scanning unit, fourth determining unit, hash value calculating unit, and target test script code information generating unit
And the scanning unit is used for scanning the test script source code to identify a test page operation object in the test script source code. In an embodiment, the scanning unit may be configured to perform the operation S2111 described above, which is not described herein.
And a fourth determining unit, configured to determine operation action information and processing method information of the test page operation object according to the test page operation object. In an embodiment, the fourth determining unit may be configured to perform the operation S2112 described above, which is not described herein.
And the hash value calculation unit is used for carrying out hash operation on the test page operation object so as to generate a hash value. In an embodiment, the hash value calculation unit may be used to perform the operation S2113 described above, which is not described herein.
And the target test script code information generating unit is used for generating target test script code information according to the test page operation object information, the operation action information, the processing method information and the hash value. In an embodiment, the target test script code information generating unit may be configured to perform the operation S2114 described above, which is not described herein.
According to an embodiment of the present disclosure, a word frequency analysis submodule includes: the system comprises a first target code generation sub-module, a calculation sub-module and a word frequency analysis result generation sub-module.
And the first target code generation sub-module is used for extracting the target test script codes according to a script execution sequence according to a preset step length so as to generate the first target codes. In an embodiment, the first object code generating sub-module may be configured to perform the operation S2121 described above, which is not described herein.
And the computing sub-module is used for computing word frequency information of the first target code. In an embodiment, the calculation sub-module may be used to perform the operation S2122 described above, which is not described herein.
And the word frequency analysis result generation sub-module is used for generating a word frequency analysis result according to the word frequency information. In an embodiment, the word frequency analysis result generation sub-module may be used to perform the operation S2123 described above, which is not described herein.
According to embodiments of the present disclosure, any of the initial common code segment determination module 910, the cluster analysis module 920, the common code segment set generation module 930, the target common code segment determination module 940, and the target common code block generation module 950 may be combined in one module to be implemented, or any of them may be split into a plurality of modules. Alternatively, at least some of the functionality of one or more of the modules may be combined with at least some of the functionality of other modules and implemented in one module. According to embodiments of the present disclosure, at least one of the initial common code segment determination module 910, the cluster analysis module 920, the common code segment set generation module 930, the target common code segment determination module 940, and the target common code block generation module 950 may be implemented at least in part as hardware circuitry, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system-on-chip, a system-on-substrate, a system-on-package, an Application Specific Integrated Circuit (ASIC), or as hardware or firmware in any other reasonable manner of integrating or packaging the circuitry, or as any one of or a suitable combination of any of the three implementations of software, hardware, and firmware. Alternatively, at least one of the initial common code segment determination module 910, the cluster analysis module 920, the common code segment set generation module 930, the target common code segment determination module 940, and the target common code block generation module 950 may be at least partially implemented as a computer program module, which when executed, may perform the corresponding functions.
Fig. 10 schematically illustrates a block diagram of an electronic device adapted to implement a method of encapsulation of test script code, in accordance with an embodiment of the present disclosure.
As shown in fig. 10, an electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. The processor 1001 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or an associated chipset and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. The processor 1001 may also include on-board memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flows according to embodiments of the present disclosure.
In the RAM 1003, various programs and data necessary for the operation of the electronic apparatus 1000 are stored. The processor 1001, the ROM 1002, and the RAM 1003 are connected to each other by a bus 1004. The processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing programs in the ROM 1002 and/or the RAM 1003. Note that the program may be stored in one or more memories other than the ROM 1002 and the RAM 1003. The processor 1001 may also perform various operations of the method flow according to the embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the disclosure, the electronic device 1000 may also include an input/output (I/O) interface 1005, the input/output (I/O) interface 1005 also being connected to the bus 1004. The electronic device 1000 may also include one or more of the following components connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output portion 1007 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk or the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The drive 1010 is also connected to the I/O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is installed as needed in the drive 1010, so that a computer program read out therefrom is installed as needed in the storage section 1008.
The present disclosure also provides a computer-readable storage medium that may be embodied in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs that, when executed, implement the method of packaging test script code according to embodiments of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, the computer-readable storage medium may include ROM 1002 and/or RAM 1003 and/or one or more memories other than ROM 1002 and RAM 1003 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowcharts. When the computer program product runs in a computer system, the program code is used for enabling the computer system to realize the encapsulation method of the test script code provided by the embodiment of the disclosure.
The above-described functions defined in the system/apparatus of the embodiments of the present disclosure are performed when the computer program is executed by the processor 1001. The systems, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted in the form of signals on a network medium, distributed, and downloaded and installed via the communication section 1009, and/or installed from the removable medium 1011. The computer program may include program code that may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 1009, and/or installed from the removable medium 1011. The above-described functions defined in the system of the embodiments of the present disclosure are performed when the computer program is executed by the processor 1001. The systems, devices, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
According to embodiments of the present disclosure, program code for performing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, such computer programs may be implemented in high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. Programming languages include, but are not limited to, such as Java, c++, python, "C" or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that the features recited in the various embodiments of the disclosure and/or in the claims may be provided in a variety of combinations and/or combinations, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, the features recited in the various embodiments of the present disclosure and/or the claims may be variously combined and/or combined without departing from the spirit and teachings of the present disclosure. All such combinations and/or combinations fall within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be made by those skilled in the art without departing from the scope of the disclosure, and such alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (16)

1. A method of packaging test script code, the method comprising:
responding to the packaging instruction of the test script code, and carrying out first similarity analysis on the test script source code to determine an initial public code section;
Performing cluster analysis on the initial public code segments to generate a plurality of public code clusters;
forming a common code segment set by using initial common code segments, the called times of which are larger than a first preset threshold value, in the common code clusters;
performing public script encapsulation based on the public code segment set to determine a target public code segment; and
and secondarily packaging the target public code segment according to a preset packaging rule to generate a target public code block.
2. The method of claim 1, wherein performing cluster analysis on the initial common code segment to generate a plurality of common code clusters comprises:
and performing second similarity analysis on the initial common code segments to generate a plurality of common code clusters.
3. The method of claim 2, wherein said performing a second similarity analysis on said initial common code segment to generate a plurality of common code clusters comprises:
taking any initial public code segment as a class, and calculating the similarity between other initial public code segments and any initial public code segment;
combining the initial public code segments with the similarity larger than a second preset threshold value to form a new classification; and
And carrying out multi-round clustering until the similarity between the current initial common code segments is smaller than a second preset threshold value.
4. The method of claim 1, wherein forming the initial common code segment of the common code cluster that has been called more than a first preset threshold into a common code segment set comprises:
counting the called times of initial public code segments in the public code clusters; and
and sequencing the initial common code segments with the called times larger than a first preset threshold value to generate a common code segment set.
5. The method of claim 1, wherein said public script packaging based on said set of public code segments to determine a target public code segment comprises:
determining the same code segment and different code segments in the common code segment set through text content comparison;
combining the same code segments; and
and carrying out branch judgment processing on the different code segments.
6. The method of claim 1, wherein secondarily packaging the target common code segment according to a preset packaging rule to generate the target common code block comprises:
Determining a target encapsulation rule according to the type of the operation object in the target public code section; and
and encapsulating the target public code segment according to the target encapsulation rule to generate a target public code block.
7. The method of claim 6, wherein said determining a target encapsulation rule based on the type of operand in the common code comprises:
if the operation object type is determined to be the browser connection operation, determining the target encapsulation rule to be the operation of adding waiting and window maximization after the browser connection operation is acquired;
if the operation object type is determined to be the click operation, determining the target encapsulation rule to be to increase the waiting time after the click operation; and
and if the operation object type is determined to be the input operation, determining the target encapsulation rule to be a click operation added with the same element before the input operation.
8. The method of claim 1, further comprising, after generating the target common code block:
verifying the validity of the target public code block; and
and generating a public code block management list according to the validity verification result.
9. The method of claim 8, wherein verifying the validity of the target common code block comprises:
replacing the corresponding public code segments in the test script with the target public code blocks to generate a target test script;
executing the target test script to obtain the execution success rate of the target test script;
when the execution success rate is greater than or equal to a third preset threshold value, determining that the target public code block is valid; and
and when the execution success rate is determined to be smaller than a third preset threshold value, determining that the target public code block is invalid.
10. The method of any of claims 1 to 9, wherein performing a first similarity analysis on test script source code to determine an initial common code segment comprises:
preprocessing the test script source code to generate target test script code information;
performing word frequency analysis on the target test script code information by using a text keyword extraction algorithm to generate a word frequency analysis result; and
and determining codes with word frequency larger than a fourth preset threshold value in the target test script code information as initial public code segments.
11. The method of claim 10, wherein preprocessing the test script source code to generate target test script code information comprises:
scanning a test script source code to identify a test page operation object in the test script source code;
determining operation action information and processing method information of the test page operation object according to the test page operation object;
performing hash operation on the test page operation object to generate a hash value; and
and generating target test script code information according to the test page operation object information, the operation action information, the processing method information and the hash value.
12. The method of claim 10, wherein performing word frequency analysis on the target test script code information using a text keyword extraction algorithm to generate a word frequency analysis result comprises:
extracting the target test script codes according to a script execution sequence according to a preset step length to generate first target codes;
calculating word frequency information of the first target code; and
and generating a word frequency analysis result according to the word frequency information.
13. A packaging apparatus for testing script code, the apparatus comprising:
the initial public code segment determining module is used for responding to the packaging instruction of the test script code and carrying out first similarity analysis on the test script source code so as to determine an initial public code segment;
the cluster analysis module is used for carrying out cluster analysis on the initial public code segments so as to generate a plurality of public code clusters;
the public code segment set generation module is used for forming a public code segment set from initial public code segments, of which the called times are larger than a first preset threshold, in the public code clusters;
the target public code segment determining module is used for carrying out public script encapsulation based on the public code segment set so as to determine target public code segments; and
and the target public code block generation module is used for encapsulating the target public code segments according to preset encapsulation rules to generate target public code blocks.
14. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of packaging test script code according to any of claims 1-12.
15. A computer readable storage medium having stored thereon executable instructions which when executed by a processor cause the processor to perform a method of packaging test script code according to any of claims i-12.
16. A computer program product comprising a computer program which, when executed by a processor, implements a method of encapsulating test script code according to any of claims 1-12.
CN202310429808.0A 2023-04-20 2023-04-20 Packaging method and device for test script code Pending CN117170659A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310429808.0A CN117170659A (en) 2023-04-20 2023-04-20 Packaging method and device for test script code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310429808.0A CN117170659A (en) 2023-04-20 2023-04-20 Packaging method and device for test script code

Publications (1)

Publication Number Publication Date
CN117170659A true CN117170659A (en) 2023-12-05

Family

ID=88940054

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310429808.0A Pending CN117170659A (en) 2023-04-20 2023-04-20 Packaging method and device for test script code

Country Status (1)

Country Link
CN (1) CN117170659A (en)

Similar Documents

Publication Publication Date Title
CN105283849B (en) For the Parallel Tracking of performance and details
US11823072B2 (en) Customer behavior predictive modeling
US8234692B2 (en) System and method for processing an upload of a program with export compliance information
US11915195B2 (en) Systems and methods for intelligent field matching and anomaly detection
CN109815147B (en) Test case generation method, device, server and medium
US20090259685A1 (en) Infrastructure and Architecture for Development and Execution of Predictive Models
US11637839B2 (en) Automated and adaptive validation of a user interface
CN111783039B (en) Risk determination method, risk determination device, computer system and storage medium
CN111612040B (en) Financial data anomaly detection method and related device based on isolated forest algorithm
US11687839B2 (en) System and method for generating and optimizing artificial intelligence models
US20230004979A1 (en) Abnormal behavior detection method and apparatus, electronic device, and computer-readable storage medium
CN110688111A (en) Configuration method, device, server and storage medium of business process
JP7170689B2 (en) Output device, output method and output program
CN110704273B (en) Processing method and device of configuration information, electronic equipment and storage medium
Pan et al. Gray computing: A framework for computing with background javascript tasks
Gültekin et al. Variable importance analysis in default prediction using machine learning techniques
van Dinter et al. Just-in-time defect prediction for mobile applications: using shallow or deep learning?
CN117170659A (en) Packaging method and device for test script code
CN115080433A (en) Testing method and device based on flow playback
US8458205B2 (en) Identifying a group of products relevant to data provided by a user
US20210312223A1 (en) Automated determination of textual overlap between classes for machine learning
CN113609018A (en) Test method, training method, device, apparatus, medium, and program product
Steurer Kafka: Real-Time Streaming for the Finance Industry
CN117130903A (en) Packaging method and device for test script code
CN112596781A (en) Service execution and service configuration method and device

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