CN116627792A - Test code optimization method, apparatus, device, medium and program product - Google Patents

Test code optimization method, apparatus, device, medium and program product Download PDF

Info

Publication number
CN116627792A
CN116627792A CN202310079152.4A CN202310079152A CN116627792A CN 116627792 A CN116627792 A CN 116627792A CN 202310079152 A CN202310079152 A CN 202310079152A CN 116627792 A CN116627792 A CN 116627792A
Authority
CN
China
Prior art keywords
test
sentences
type
optimized
optimization
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
CN202310079152.4A
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 CN202310079152.4A priority Critical patent/CN116627792A/en
Publication of CN116627792A publication Critical patent/CN116627792A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/368Test management for test version control, e.g. updating test cases to a new software version

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure provides a test code optimization method, which can be applied to the field of software testing, and can be used for financial science and technology, artificial intelligence and the like. The test code optimization method comprises the following steps: obtaining a test script code, wherein the test script code comprises a plurality of test sentences, the test sentences comprise a plurality of fields, and the plurality of test sentences are formed by recording manual test operation; identifying the plurality of test sentences according to a preset identification rule, and screening sentences to be optimized, wherein the sentences to be optimized are formed based on redundant operation in manual test operation, and the sentences to be optimized comprise a plurality of optimization types; and optimizing the statement to be optimized based on a preset optimization rule corresponding to the optimization type. The present disclosure also provides a test code optimization apparatus, device, storage medium, and program product.

Description

Test code optimization method, apparatus, device, medium and program product
Technical Field
The present disclosure relates to the field of software testing, and may be used in financial science, artificial intelligence, etc., and in particular to a test code optimization method, apparatus, device, medium, and program product.
Background
In the process of developing an information system, a layering test mode is generally adopted to ensure the version quality of the system to the greatest extent. Along with the development of business, the complexity of transaction flow and the number of service functions in an information system are greatly improved, the scale of stock functions to be verified in each version is larger and larger, but the update period requirement of the version is shorter and shorter, the test manpower resources are more and more precious, and the traditional manual test mode can not meet the current requirements, so that a large number of financial enterprises introduce an automatic test framework in a test link, and test efficiency is improved and the investment of the test manpower resources is reduced by writing an automatic test script by a test personnel and automatically executing the test script.
In order to improve the working efficiency, in the stage of generating test codes, testers usually adopt some automatic test tools with script recording functions to perform automatic script writing, when the testers begin to write the scripts, the testers record that the testers finish operation in a browser through the automatic test tools, and the test tools automatically form corresponding automatic test scripts, so that compared with a manual line-by-line writing mode, the automatic test script writing efficiency can be greatly improved in the mode
However, since the user is unaware of redundant operations during the testing process, these redundant operations will form redundant test codes, which will bring about significant meaningless resource overhead and time overhead for the version test work.
Therefore, how to optimize these redundant test codes is a technical problem to be solved.
Disclosure of Invention
In view of the foregoing, the present disclosure provides test code optimization methods, apparatuses, devices, media, and program products that improve test code execution efficiency and test code application scenarios.
According to a first aspect of the present disclosure, there is provided a test code optimization method comprising: obtaining a test script code, wherein the test script code comprises a plurality of test sentences, the test sentences comprise a plurality of fields, and the plurality of test sentences are formed by recording manual test operation; identifying the plurality of test sentences according to a preset identification rule, and screening sentences to be optimized, wherein the sentences to be optimized are formed based on redundant operation in manual test operation, and the sentences to be optimized comprise a plurality of optimization types; and optimizing the statement to be optimized based on a preset optimization rule corresponding to the optimization type.
According to an embodiment of the disclosure, the optimization type includes: the repeatability type at least comprises a first repeatability type, the multiple test sentences are identified according to a preset identification rule, and sentences to be optimized are screened, and the method comprises the following steps: judging whether at least two continuous and same test sentences exist in the plurality of test sentences; and determining that the two continuous and identical test sentences are sentences to be optimized of the first repeatability type under the condition that a plurality of continuous and identical test sentences are judged.
According to an embodiment of the present disclosure, the repeatability types further include at least a second repeatability type, the identifying the plurality of test sentences according to a preset identification rule, screening sentences to be optimized, and further includes: summarizing object definition fields in the plurality of test sentences, wherein the test sentences in which the object definition fields are positioned comprise object fields; judging whether at least two test sentences which are in the test sentences with the object definition fields contain the same object definition field or not; and determining that the test statement in which the definition field is located is of a second rendition type in the case that the same object definition field is contained in the at least two test statements.
According to an embodiment of the present disclosure, the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type includes: for the first repeatability type, reserving one of at least two test sentences corresponding to the first repeatability type; and for the second repeatability type, reserving one of at least two test sentences corresponding to the second repeatability type.
According to an embodiment of the present disclosure, the optimizing type includes an invalidity type, the invalidity type includes at least a first invalidity type, and the optimizing the statement to be optimized based on a preset optimizing rule corresponding to the optimizing type includes: judging whether at least two input fields exist in the plurality of test sentences, wherein the test sentences in which the at least two input fields are positioned are continuous; judging whether the test statement in which the input fields are located has a content field or not under the condition that the at least two input fields exist and the test statement in which the at least two input fields are located is continuous; and determining that the test statement in which the input field is located is of a first type of invalidity under the condition that the content field exists in the test statement in which the input field is located.
According to an embodiment of the present disclosure, the invalidity type further includes a second invalidity type, and the optimizing the statement to be optimized based on a preset optimization rule corresponding to the optimization type further includes: judging whether click fields exist in the test sentences; judging whether a text box field exists in the test statement in which the click field exists or judging whether click coordinates exist in the test statement in which the click field exists or not under the condition that whether the click field exists in the plurality of test statements; determining that the sentence to be optimized, in which the click field is located, is of a second invalidity type when the text box field exists in the test sentence in which the click field is located or when the click coordinate exists in the test sentence in which the click field is located; or judging whether a drag field exists in the plurality of test sentences; and under the condition that a drag field exists in the plurality of test sentences, determining that the sentence to be optimized where the drag field exists is of a second invalidity type.
According to an embodiment of the present disclosure, the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type includes: for the first invalidity type, reserving the last test statement in at least two test statements corresponding to the first invalidity type; and deleting the test statement of the second invalidity type for the second invalidity type.
According to an embodiment of the present disclosure, the optimizing type includes a mergence type, and the optimizing the statement to be optimized based on a preset optimizing rule corresponding to the optimizing type includes: judging whether at least two continuous test sentences contain the same selection field or not in the plurality of test sentences; and under the condition that at least two continuous test sentences contain the same selection field in the plurality of test sentences, determining that the sentence to be optimized where the selection field is located is the mergence type.
According to an embodiment of the present disclosure, the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type includes: and merging the at least two continuous test sentences into one test sentence for the mergence type.
In a second aspect of the present disclosure, there is provided a test code optimizing apparatus comprising: the system comprises an acquisition module, a recording module and a processing module, wherein the acquisition module is used for acquiring test script codes, the test script codes comprise a plurality of test sentences, the test sentences comprise a plurality of fields, and the plurality of test sentences are formed by recording manual test operation; the recognition module is used for recognizing the plurality of test sentences according to a preset recognition rule, and screening sentences to be optimized, wherein the sentences to be optimized are formed based on redundant operation in manual test operation, and the sentences to be optimized comprise a plurality of optimization types; and the optimizing module is used for optimizing the statement to be optimized based on a preset optimizing rule corresponding to the optimizing type.
According to an embodiment of the disclosure, the optimization type includes: the identification module comprises a repeatability identification sub-module and is used for judging whether at least two continuous and same test sentences exist in the plurality of test sentences or not; and determining that the two continuous and identical test sentences are sentences to be optimized of the first repeatability type under the condition that a plurality of continuous and identical test sentences are judged.
According to an embodiment of the present disclosure, the repeatability type further includes at least a second repeatability type, and the repeatability identifying sub-module is further configured to summarize object definition fields in the multiple test sentences, where the object definition fields are located in the test sentences, and include object fields; judging whether at least two test sentences which are in the test sentences with the object definition fields contain the same object definition field or not; and determining that the test statement in which the definition field is located is of a second rendition type in the case that the same object definition field is contained in the at least two test statements.
According to an embodiment of the disclosure, the optimizing module includes a repeatability optimizing sub-module, configured to, for the first repeatability type, reserve one of at least two test sentences corresponding to the first repeatability type; and for the second repeatability type, reserving one of at least two test sentences corresponding to the second repeatability type.
According to an embodiment of the disclosure, the optimization type includes an invalidity type, the invalidity type includes at least a first invalidity type, and the recognition module includes an invalidity recognition sub-module, configured to determine whether at least two input fields exist in the plurality of test sentences, where the test sentences in which the at least two input fields are located are continuous; judging whether the test statement in which the input fields are located has a content field or not under the condition that the at least two input fields exist and the test statement in which the at least two input fields are located is continuous; and determining that the test statement in which the input field is located is of a first type of invalidity under the condition that the content field exists in the test statement in which the input field is located.
According to the embodiment of the disclosure, the invalidity type further comprises a second invalidity type, and the invalidity identification sub-module is further used for judging whether a click field exists in the plurality of test sentences; judging whether a text box field exists in the test statement in which the click field exists or judging whether click coordinates exist in the test statement in which the click field exists or not under the condition that whether the click field exists in the plurality of test statements; determining that the sentence to be optimized, in which the click field is located, is of a second invalidity type when the text box field exists in the test sentence in which the click field is located or when the click coordinate exists in the test sentence in which the click field is located; or judging whether a drag field exists in the plurality of test sentences; and under the condition that a drag field exists in the plurality of test sentences, determining that the sentence to be optimized where the drag field exists is of a second invalidity type.
According to an embodiment of the disclosure, the optimizing module includes an invalidity optimizing sub-module, configured to, for the first invalidity type, reserve a last test statement of at least two test statements corresponding to the first invalidity type; and deleting the test statement of the second invalidity type for the second invalidity type.
According to an embodiment of the present disclosure, the optimization type includes a mergence type, and the identification module includes a mergence identification sub-module, configured to determine whether at least two consecutive test sentences in the plurality of test sentences each include the same selection field; and under the condition that at least two continuous test sentences contain the same selection field in the plurality of test sentences, determining that the sentence to be optimized where the selection field is located is the mergence type.
According to an embodiment of the disclosure, the optimizing module includes a merger optimizing sub-module configured to merge the at least two consecutive test sentences into one test sentence for the merger type.
In a third aspect of the present disclosure, there is provided 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 test code optimization method described above.
In a fourth aspect of the present disclosure, there is also provided a computer readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the above-described test code optimization method.
In a fifth aspect of the present disclosure, there is also provided a computer program product comprising a computer program which, when executed by a processor, implements the above-described test code optimization method.
In the embodiment of the disclosure, invalid and redundant codes are screened out by identifying and analyzing the redundant codes generated by misoperation or redundant operation of a user, and corresponding optimization operation is performed on the codes, so that the code quantity is reduced, the quality of automatic test script codes is improved, the efficient execution of a test flow is ensured, and the version management efficacy is improved.
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 an application scenario diagram of a test code optimization method according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a test code optimization method according to an embodiment of the disclosure;
FIG. 3A schematically illustrates a flow chart of a method of identifying statements to be optimized according to an embodiment of the disclosure;
FIG. 3B schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure;
FIG. 3C schematically illustrates a flow chart of a statement to be optimized optimization method in accordance with an embodiment of the disclosure;
FIG. 4A schematically illustrates a flow chart of a method of identifying statements to be optimized according to an embodiment of the disclosure;
FIG. 4B schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure;
FIG. 4C schematically illustrates a flow chart of a statement optimization method to be optimized in accordance with an embodiment of the disclosure
FIG. 5A schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure;
FIG. 5B schematically illustrates a flow chart of a statement to be optimized optimization method in accordance with an embodiment of the disclosure;
FIG. 6 schematically illustrates a block diagram of a test code optimization apparatus according to an embodiment of the disclosure; and
fig. 7 schematically illustrates a block diagram of an electronic device adapted to implement a test code optimization method according to an embodiment of the 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.).
With the development of IT technology, more and more financial enterprises adopt a centralized deployment mode in the information system construction process to realize standardized and unified service capability for users, and generally, the system service adopts a B/S architecture, so that users can access the information system by using a browser, and the prepared resource requirements of required equipment are reduced to the greatest extent when the users access the information system.
In the process of developing a B/S type information system, a layering test mode is generally adopted to ensure the version quality of the system to the greatest extent: the unit test stage is mainly used for verifying the coverage rate of codes and the problem of simple path branching errors; the interface test stage is mainly used for verifying whether an independent interface service can realize the functions provided by the interface according to expectations; the integration test stage is mainly used for verifying whether the corresponding function adaptation can be completed according to the original program design when a plurality of interfaces are called; and in the acceptance test stage, whether the system can provide correct transaction response from a complete customer service scene or not is verified through real scene test mainly from the view point of an end user. And in each test stage, sufficient test verification is required, after the test is passed, the on-line security of the information system version can be achieved, and finally the information system is deployed into a production environment for operation and maintenance.
Because the financial enterprises have high requirements on the quality of the version of the information system, each test stage needs to complete corresponding test verification, and therefore, an automatic test framework of a corresponding type needs to be introduced in different test stages to develop automatic test work. In order to improve working efficiency, a tester usually adopts some automatic test tools with script recording functions to perform automatic script writing, when the tester starts to write a script, the tester records that the tester completes operation in a browser through the automatic test tools, and the test tools automatically form corresponding automatic test scripts.
Usually, a tester also manually identifies part of invalid codes in the codes to delete, and integrates combinable codes, but takes a great deal of working time of the tester. Therefore, a technical scheme is urgently needed, automatic scanning and intelligent analysis can be performed on automatic test script codes after script writing is completed, optimized operation sentences can be found, invalid operation sentences are automatically deleted, similar codes are combined, quality of the automatic test script is improved, waste of automatic test execution resources is reduced, and execution efficiency of the automatic test script is improved.
The embodiment of the disclosure provides a test code optimization method, which comprises the steps of obtaining a test script code, wherein the test script code comprises a plurality of test sentences, the test sentences comprise a plurality of fields, and the plurality of test sentences are formed by recording manual test operation; identifying the plurality of test sentences according to a preset identification rule, and screening sentences to be optimized, wherein the sentences to be optimized are formed based on redundant operation in manual test operation, and the sentences to be optimized comprise a plurality of optimization types; and optimizing the statement to be optimized based on a preset optimization rule corresponding to the optimization type.
In the embodiment of the disclosure, invalid and redundant codes are screened out by identifying and analyzing the redundant codes generated by misoperation or redundant operation of a user, and corresponding optimization operation is performed on the codes, so that the code quantity is reduced, the quality of automatic test script codes is improved, the efficient execution of a test flow is ensured, and the version management efficacy is improved.
Fig. 1 schematically illustrates an application scenario diagram of a test code optimization method according to an embodiment of the present disclosure.
As shown in fig. 1, an application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. 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 server providing various services, such as a background management server (by way of example only) providing support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and process the received data such as the user request, and feed back the processing result (e.g., the web page, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the test code optimization method provided by the embodiments of the present disclosure may be generally performed by the server 105. Accordingly, the test code optimization apparatus provided by the embodiments of the present disclosure may be generally provided in the server 105. The test code optimization method 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 test code optimization apparatus provided by the embodiments of the present disclosure may also be provided in 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.
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.
The test code optimization method of the disclosed embodiment will be described in detail below with reference to the scenario described in fig. 1 through fig. 2 to 5B.
FIG. 2 schematically illustrates a flow chart of a test code optimization method according to an embodiment of the disclosure.
As shown in fig. 2, the test code optimization of this embodiment includes operations S210 to S230, and the test code optimization method may be performed by the server 105.
In operation S210, a test script code is acquired, the test script code including a plurality of test sentences, wherein the test sentences include a plurality of fields, the plurality of test sentences being formed by recording a manual test operation.
Specifically, a tester records the operation in a browser through an automatic test tool, and the test tool automatically forms a corresponding automatic test script to record the script to form the test script code. Wherein, a test script code comprises a plurality of test sentences, and one test sentence corresponds to one test operation of a tester.
Taking the operation of clicking on a page element on a certain page as an example, a test statement corresponding to the operation is as follows: browser ("system a"), page ("system B"), webElement ("ok"), click, i.e., a tester clicks on the Page element "confirm" on the Page "system B" of Browser "system a". Wherein Browser, system A, page, system B, webElement, ok, and Click are each a field.
In operation S220, the multiple test sentences are identified according to a preset identification rule, and sentences to be optimized are screened, wherein the sentences to be optimized are formed based on redundant operations in manual test operations, and the sentences to be optimized comprise multiple optimization types.
The research and development personnel summarize that whether the test operation of the tester is a redundant operation generally follows three principles, namely repeatability, invalidity and mergeability, and the code sentences formed by the redundant operations are also identified and optimized by adopting the three principles. The redundant operations of the different principles are sentences to be optimized after being converted into codes, and correspondingly, the classification principles of the redundant operations are optimization types after being converted into codes. Specifically, for the preset recognition rule, the following table 1 may be used:
TABLE 1
As shown in table 1, the table summarizes the recognition principle of redundant operations on different principles, where repeatability includes: 1. continuously clicking the same element for a plurality of times; 2. continuously inputting the same content for a plurality of times to the same text box; 3. the same object is repeatedly defined. Invalidity includes: 1. the input content is empty, and a non-empty value is input later; 2. clicking the text box, but without input action; 3. clicking the independent coordinates; 4. invalid drag. The mergence includes: 1. combining menu clicking; 2 drop down boxes select merge. Wherein, the above elements refer to page elements.
In operation S230, the statement to be optimized is optimized based on a preset optimization rule corresponding to the optimization type.
Correspondingly, after the different redundant operations are identified, adopting a corresponding optimization mode for codes formed by the specific redundant operations, and adopting a corresponding pre-designed optimization means for the sentences to be optimized of different optimization types.
In the embodiment of the disclosure, invalid and redundant codes are screened out by identifying and analyzing the redundant codes generated by misoperation or redundant operation of a user, and corresponding optimization operation is performed on the codes, so that the code quantity is reduced, the quality of automatic test script codes is improved, the efficient execution of a test flow is ensured, and the version management efficacy is improved.
Next, the recognition and optimization scheme of the statement to be optimized will be specifically disclosed in detail, as follows:
fig. 3A schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure.
As shown in fig. 3A, the statement identification to be optimized of this embodiment includes operations S310 to S320. The operations S310 to S320 may at least partially perform the operation S220 described above.
In operation S310, it is determined whether there are at least two consecutive and identical test sentences among the plurality of test sentences.
In operation S320, in case that it is determined that a plurality of consecutive and identical test sentences are determined, the two consecutive and identical test sentences are sentences to be optimized of the first repeatability type.
That is, the determination preconditions for the first recurring type of statement to be optimized must be consecutive test statements. In addition, when the first repeatability type is optimized later, the influence scope of the considered sentences to be optimized is also that the sentences to be optimized of several continuous first repeatability types are one optimization task. Different, discrete, repeating content performs respective optimization logic.
Fig. 3B schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure.
As shown in fig. 3B, the statement identification to be optimized of this embodiment includes operations S330 to S350. The operations S330 to S350 may at least partially perform the operation S220 described above.
In operation S330, object definition fields in the plurality of test sentences are summarized, where the test sentences in which the object definition fields are located include object fields.
In operation S340, it is determined whether at least two test sentences including the same object definition field exist in the test sentence in which the object definition field exists.
In operation S350, in case that the same object definition field is included in the at least two test sentences, it is determined that the test sentence in which the definition field is located is of a second duplicate type.
Specifically, the created object has the same name, namely is regarded as one, and is created once in one test script code, and if created multiple times, the created object is regarded as repeated definition. The object definition field refers to a field in code that can indicate that an object is created or defined, for example, "creatobjected", and the object field refers to an object defined by the object definition field, for example, "CreatObject (A)", and then refers to a defined object "a".
Fig. 3C schematically illustrates a flowchart of a statement to be optimized optimization method according to an embodiment of the disclosure.
As shown in fig. 3C, the statement to be optimized optimization of this embodiment includes operations S360 to S370. The operations S360 to S370 may at least partially perform the above-described operation S230.
In operation S360, for the first repeatability type, one of at least two test sentences corresponding to the first repeatability type is reserved.
That is, the optimization scheme for the first repeatability type is: when several consecutive test sentences with the same content appear, redundant test sentences are deleted, and only one test sentence is finally reserved. Of course, when the determination of the deletion range is determined when a plurality of repeated test sentences are consecutive, it can be said that these consecutive test sentences are the range of one deletion. However, when there is an interval between the plurality of repeated test sentences, the respective optimization tasks are calculated according to the regulations, and then the respective optimization works are performed.
In operation S370, for the second repeatability type, one of at least two test sentences corresponding to the second repeatability type is reserved.
That is, the optimization scheme for the second type of reproducibility is: the redundant test sentences of the definition objects are deleted, and only the test sentence of one definition object is reserved, and of course, the test sentence of the first definition object can be reserved in some cases. Of course, the scope of deletion or influence is established throughout the script and does not require that the redefined test statement be contiguous, e.g., if there are multiple identically defined objects in the script, then the redundant objects are deleted and only the test statement that defines the object portion first remains.
The identification and optimization of test codes involving the repeatability principle will be further described by way of example:
specifically, the specific rule corresponding to the first repeatability type includes: 1. carrying out continuous points on the same element for a plurality of times; 2. the same content is consecutively input a plurality of times to the same text box.
1. For multiple consecutive points on the same element, the specific rule is characterized in that: clicking on the same element twice or more, there are no other operations in the clicking process. For example:
browser ("System A"), page ("System B"), webElement ("determining"), click
Browser ("System A"), page ("System B"), webElement ("determining"), click
Browser ("System A"), page ("System B"), webElement ("determining"), click
Redundant repeated test sentences can be deleted, and the method can be specifically modified as follows:
browser ("System A"), page ("System B"), webElement ("determining"), click
And deleting redundant Click operations, and only reserving one Click on the page element.
2. For the same text box, the same content is continuously input for a plurality of times, and the specific rule is characterized in that: the same input action is performed on the same input item. For example:
browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 1"
Browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 1"
Browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 1"
Redundant redefined test statements may be deleted, and specifically modified as follows:
browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 1"
Specifically, the specific rule corresponding to the second repeatability type includes: the same object is repeatedly defined. For example:
Dim device1
Set device1 = CreateObject ("object a")
device1.SendString ("string 1")
Browse (System A), page ("MP"), frame ("MainFrame"), webButton ("Login"), click
Dim device2
Set device2 = CreateObject ("object a")
device2.SendString ("string 2')
Browse (System A), page ("MP"), frame ("MainFrame"), webButton ("Login"), click
Dim device3
Set device3 = CreateObject ("object a")
device3.SendString ("string 3')
The CreateObject keywords are summarized, names in the following (") are counted, repeated variable names are extracted if the names appear twice, then variable names defined for the first time are reserved, variable definitions at other positions are deleted, and variable names used at other positions are changed into variable names appearing for the first time.
Fig. 4A schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure.
As shown in fig. 4A, the statement identification to be optimized of this embodiment includes operations S410 to S430. The operations S410 to S430 may at least partially perform the operation S220 described above.
In operation S410, it is determined whether there are at least two input fields in the plurality of test sentences, and the test sentences in which the at least two input fields are located are consecutive.
In operation S420, in case that there are at least two input fields and the test statement in which the at least two input fields are located is continuous, it is determined whether there is a content field in the test statement in which the input fields are located.
In operation S430, in case that the content field exists in the test sentence in which the input field is located, it is determined that the test sentence in which the input field is located is of the first validity type.
It will be appreciated that the user operation corresponding to the first invalidity type is a continuous input operation on the same inputtable element, and in this process, the content of the general input is determined to be the last input, and then the input is not the input which is invalid for the last time.
Fig. 4B schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure.
As shown in fig. 4B, the statement identification to be optimized of this embodiment includes operations S440 to S480. The operations S440 to S480 may at least partially perform the operation S220 described above.
In operation S440, it is determined whether a click field exists in the plurality of test sentences.
In operation S450, if a click field exists in the multiple test sentences, it is determined whether a text box field exists in the test sentence in which the click field exists, or whether click coordinates exist in the test sentence in which the click field exists.
In operation S460, in the case where the text box field exists in the test sentence in which the click field is located, or in the case where it is determined that the click coordinate exists in the test sentence in which the click field is located, it is determined that the sentence to be optimized in which the click field is located is of the second invalidity type.
In operation S470, it is determined whether a drag field exists in the plurality of test sentences.
In operation S480, if a drag field exists in the multiple test sentences, determining that the sentence to be optimized where the drag field exists is of a second invalidity type.
Of course, for the second invalidity type, there are many invalidity operations performed by a mouse pointer during a user operation, such as an invalid click, an invalid drag, and the like.
The judgment of whether the element is invalid is based on whether the same element is subjected to the same operation. The judgment basis of the same element is that the element types are the same and the element names are the same (for example, webEdit and the names are remarks) and the input operation (Set operation) is carried out on the element, so that the last input content is taken as the final content (because the last input content is covered by the input content of the next sentence no matter what is input before), and of course, the premise that the first invalidity type and the second invalidity type are judged is emphasized, and continuous test sentences are needed.
Fig. 4C schematically illustrates a flowchart of a statement to be optimized optimization method according to an embodiment of the disclosure.
As shown in fig. 4C, the statement optimization to be optimized of this embodiment includes operations S490 to S4100. The operations S490 to S4100 may be at least partially performed in the operation S230.
In operation S490, for the first invalidity type, a last test statement of at least two test statements corresponding to the first invalidity type is reserved.
In operation S4100, for the second invalidity type, test statements of the second invalidity type are deleted.
In the following, by way of example, the identification and optimization of test codes involving invalidity principles will be further described:
specifically, the specific rule corresponding to the first invalidity type includes: the same element is input, the input content is null, and the non-null value is input later.
For the input content being null and subsequently inputting non-null values, the specific rule is characterized in that: the same element is input, the input content is null, and the non-null value is input later. For example:
browser ("System A"), page ("System B"), webEdit ("remark"), set ""
Browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 1"
Browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 2
Can be modified as follows:
browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 2
Specifically, the specific rule corresponding to the second invalidity type includes: 1. clicking the text box, but without input action; 2. clicking the independent coordinates; 3. invalid drag.
1. For clicking on a text box, there is no input action. For example:
browser ("System A"), page ("System B"), webEdit ("remark"), click ""
Browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 1"
Can be modified as follows:
browser ("System A"), page ("System B"), webEdit ("remark"), set "remark 1"
2. And for single coordinate clicking, misoperation in the script recording process is caused. And deleting the file. For example:
browser ("System A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), set "string 1"
Window(″Window″).Click 336,144
Browser ("system A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), webButton ("Login"), click
Can be modified as follows:
browser ("System A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), set "string 1"
Browser ("system A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), webButton ("Login"), click
3. And for invalid dragging, the method belongs to misoperation in the script recording process. And deleting the file. For example:
browser ("System A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), set "string 1"
Browser ("System A"),. Page ("System B"),. Frame ("Main Frame"),. WebEdit ("user name" l.drag)
Browser ("system A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), drop
Browser ("system A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), webButton ("Login"), click
Can be modified as follows:
browser ("System A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), set "string 1"
Browser ("system A"), page ("System B"), frame ("Main Frame"), webEdit ("user name"), webButton ("Login"), click
Note that, for the Click of absolute coordinates (the expression mode in the script is Click operation followed by two numerical values as parameters, for example, click 336, 144), the script is regarded as invalid operation, and since the coordinate positions on the execution machines with different respective rates are different, if the Click of coordinates is needed, the Click of relative coordinates is used, and if the Click of absolute coordinates is used, the failure rate is greatly improved, so that such a sentence is regarded as an invalid sentence to be deleted directly. Likewise, the principle is equally applicable to invalid drags.
Fig. 5A schematically illustrates a flowchart of a method of identifying statements to be optimized according to an embodiment of the disclosure.
As shown in fig. 5A, the statement identification to be optimized of this embodiment includes operations S510 to S520. The operations S510 to S520 may at least partially execute the operation S220.
In operation S510, it is determined whether at least two consecutive test sentences each include the same selection field in the plurality of test sentences.
In operation S520, if it is determined that at least two consecutive test sentences in the plurality of test sentences include the same selection field, determining that the sentence to be optimized in which the selection field is located is the mergence type.
Specifically, the selection field refers to a field that can perform selection in a list or a menu, and by triggering the selection field, a fixed option in the list or the menu can be selected, for example, the selection field may be "Select" and a specific option may be "Select option a".
Fig. 5B schematically illustrates a flowchart of a statement to be optimized optimization method according to an embodiment of the disclosure.
As shown in fig. 5B, the statement to be optimized optimization of this embodiment includes operation S530. This operation S530 may at least partially perform the above-described operation S230.
In operation S530, for the merger type, the at least two consecutive test sentences are merged into one test sentence.
Specifically, the specific rule corresponding to the mergence type includes: 1. combining menu clicking; 2. the drop down boxes select merge.
1. Merging for menu clicks. For example:
browser ("System A"), page ("System B"), webMenu ("Menu"), select "information A"
Browser ("System A"), page ("System B"), webMenu ("Menu"), select "information B"
Multiple menu clicking operations can be combined into one sentence after being de-duplicated, and the method is specifically modified as follows:
Browser ("System A"),. Page ("System B"),. WebMenu ("WebMenu"),. Select "info A; information B
Specifically, the type a and the type B in the respective selection menu are combined into one selection sentence.
2. Click merge for drop down selection. For example:
browser ("System A"), page ("System B"), webList ("type"), select "type A"
Browser ("System A"), page ("System B"), webList ("type"), select "type B"
Multiple linked drop-down frame selection actions can be combined into one sentence, and the concrete modification is as follows:
browser ("System A"),. Page ("System B"),. WebList ("type"),. Select "type A; type B
Specifically, the type A and the type B in the selection list are combined into one selection statement.
In the embodiment of the disclosure, the processing of the combinable codes in the script firstly improves the readability of the script codes, optimizes the code structure and reduces the script failure rate caused by the environmental problem of the tested system; and secondly, when the multi-script analysis is carried out subsequently and the public script is extracted, the interference of invalid codes on the extraction of the public code segment can be reduced.
Based on the test code optimization method, the disclosure also provides a test code optimization device. The device will be described in detail below in connection with fig. 6.
Fig. 6 schematically shows a block diagram of a test code optimization apparatus according to an embodiment of the present disclosure.
As shown in fig. 6, the test code optimization apparatus 600 of this embodiment includes an acquisition module 610, an identification module 620, and an optimization module 630.
The obtaining module 610 is configured to obtain test script code, where the test script code includes a plurality of test sentences, and the test sentences include a plurality of fields, and the plurality of test sentences are formed by recording manual test operations. In an embodiment, the obtaining module 610 may be configured to perform the operation S210 described above, which is not described herein.
The recognition module 620 is configured to recognize the plurality of test sentences according to a preset recognition rule, and filter sentences to be optimized, where the sentences to be optimized are formed based on redundant operations in manual test operations, and the sentences to be optimized include a plurality of optimization types. In an embodiment, the identification module 620 may be configured to perform the operation S220 described above, which is not described herein.
The optimizing module 630 is configured to optimize the statement to be optimized based on a preset optimizing rule corresponding to the optimizing type. In an embodiment, the optimization module 630 may be configured to perform the operation S230 described above, which is not described herein.
In the embodiment of the disclosure, invalid and redundant codes are screened out by identifying and analyzing the redundant codes generated by misoperation or redundant operation of a user, and corresponding optimization operation is performed on the codes, so that the code quantity is reduced, the quality of automatic test script codes is improved, the efficient execution of a test flow is ensured, and the version management efficacy is improved.
According to an embodiment of the disclosure, the optimization type includes: the identification module comprises a repeatability identification sub-module and is used for judging whether at least two continuous and same test sentences exist in the plurality of test sentences or not; and determining that the two continuous and identical test sentences are sentences to be optimized of the first repeatability type under the condition that a plurality of continuous and identical test sentences are judged.
According to an embodiment of the present disclosure, the repeatability type further includes at least a second repeatability type, and the repeatability identifying sub-module is further configured to summarize object definition fields in the multiple test sentences, where the object definition fields are located in the test sentences, and include object fields; judging whether at least two test sentences which are in the test sentences with the object definition fields contain the same object definition field or not; and determining that the test statement in which the definition field is located is of a second rendition type in the case that the same object definition field is contained in the at least two test statements.
According to an embodiment of the disclosure, the optimizing module includes a repeatability optimizing sub-module, configured to, for the first repeatability type, reserve one of at least two test sentences corresponding to the first repeatability type; and for the second repeatability type, reserving one of at least two test sentences corresponding to the second repeatability type.
According to an embodiment of the disclosure, the optimization type includes an invalidity type, the invalidity type includes at least a first invalidity type, and the recognition module includes an invalidity recognition sub-module, configured to determine whether at least two input fields exist in the plurality of test sentences, where the test sentences in which the at least two input fields are located are continuous; judging whether the test statement in which the input fields are located has a content field or not under the condition that the at least two input fields exist and the test statement in which the at least two input fields are located is continuous; and determining that the test statement in which the input field is located is of a first type of invalidity under the condition that the content field exists in the test statement in which the input field is located.
According to the embodiment of the disclosure, the invalidity type further comprises a second invalidity type, and the invalidity identification sub-module is further used for judging whether a click field exists in the plurality of test sentences; judging whether a text box field exists in the test statement in which the click field exists or judging whether click coordinates exist in the test statement in which the click field exists or not under the condition that whether the click field exists in the plurality of test statements; determining that the sentence to be optimized, in which the click field is located, is of a second invalidity type when the text box field exists in the test sentence in which the click field is located or when the click coordinate exists in the test sentence in which the click field is located; or judging whether a drag field exists in the plurality of test sentences; and under the condition that a drag field exists in the plurality of test sentences, determining that the sentence to be optimized where the drag field exists is of a second invalidity type.
According to an embodiment of the disclosure, the optimizing module includes an invalidity optimizing sub-module, configured to, for the first invalidity type, reserve a last test statement of at least two test statements corresponding to the first invalidity type; and deleting the test statement of the second invalidity type for the second invalidity type.
According to an embodiment of the present disclosure, the optimization type includes a mergence type, and the identification module includes a mergence identification sub-module, configured to determine whether at least two consecutive test sentences in the plurality of test sentences each include the same selection field; and under the condition that at least two continuous test sentences contain the same selection field in the plurality of test sentences, determining that the sentence to be optimized where the selection field is located is the mergence type.
According to an embodiment of the disclosure, the optimizing module includes a merger optimizing sub-module configured to merge the at least two consecutive test sentences into one test sentence for the merger type.
Any of the acquisition module 610, the identification module 620, and the optimization module 630 may be combined in one module to be implemented, or any of the modules may be split into multiple modules, according to embodiments of the present disclosure. 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 acquisition module 610, the identification module 620, and the optimization module 630 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 may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging the circuitry, or in any one of or a suitable combination of any of three implementations of software, hardware, and firmware. Alternatively, at least one of the acquisition module 610, the identification module 620 and the optimization module 630 may be at least partially implemented as a computer program module, which when executed, may perform the corresponding functions.
Fig. 7 schematically illustrates a block diagram of an electronic device adapted to implement a test code optimization method according to an embodiment of the disclosure.
As shown in fig. 7, an electronic device 700 according to an embodiment of the present disclosure includes a processor 701 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. The processor 701 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 701 may also include on-board memory for caching purposes. The processor 701 may comprise a single processing unit or a plurality of processing units for performing different actions of the method flows according to embodiments of the disclosure.
In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are stored. The processor 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. The processor 701 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM 702 and/or the RAM 703. Note that the program may be stored in one or more memories other than the ROM 702 and the RAM 703. The processor 701 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, the electronic device 700 may further include an input/output (I/O) interface 705, the input/output (I/O) interface 705 also being connected to the bus 704. The electronic device 700 may also include one or more of the following components connected to the I/O interface 705: an input section 706 including a keyboard, a mouse, and the like; an output portion 707 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 708 including a hard disk or the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. The drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read therefrom is mounted into the storage section 708 as necessary.
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 which, when executed, implement methods in accordance with 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 702 and/or RAM 703 and/or one or more memories other than ROM 702 and RAM 703 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. The program code, when executed in a computer system, causes the computer system to perform the methods provided by embodiments of the present 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 701. 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, distributed over a network medium in the form of signals, downloaded and installed via the communication section 709, and/or installed from the removable medium 711. 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 709, and/or installed from the removable medium 711. 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 701. 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 (13)

1. A test code optimization method, comprising:
obtaining a test script code, wherein the test script code comprises a plurality of test sentences, the test sentences comprise a plurality of fields, and the plurality of test sentences are formed by recording manual test operation;
Identifying the plurality of test sentences according to a preset identification rule, and screening sentences to be optimized, wherein the sentences to be optimized are formed based on redundant operation in manual test operation, and the sentences to be optimized comprise a plurality of optimization types; and
and optimizing the statement to be optimized based on a preset optimization rule corresponding to the optimization type.
2. The method of claim 1, wherein the optimization type comprises: a repeatability type, said repeatability type comprising at least a first repeatability type,
the identifying the plurality of test sentences according to the preset identification rule, and screening sentences to be optimized comprises the following steps:
judging whether at least two continuous and same test sentences exist in the plurality of test sentences; and
in the case that a plurality of continuous and identical test sentences are judged, the two continuous and identical test sentences are determined to be sentences to be optimized of a first repeatability type.
3. The method of claim 2, wherein the repeatability types further comprise at least a second repeatability type,
the identifying the plurality of test sentences according to a preset identifying rule, screening sentences to be optimized, and further comprising:
Summarizing object definition fields in the plurality of test sentences, wherein the test sentences in which the object definition fields are positioned comprise object fields;
judging whether at least two test sentences which are in the test sentences with the object definition fields contain the same object definition field or not; and
and under the condition that the at least two test sentences contain the same object definition field, determining that the test sentence in which the definition field is positioned is of a second rendition type.
4. The method of claim 3, wherein the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type includes:
for the first repeatability type, reserving one of at least two test sentences corresponding to the first repeatability type; and
and for the second repeatability type, reserving one of at least two test sentences corresponding to the second repeatability type.
5. The method according to claim 1 or 2, wherein the optimization type comprises an invalidity type comprising at least a first invalidity type,
the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type comprises the following steps:
Judging whether at least two input fields exist in the plurality of test sentences, wherein the test sentences in which the at least two input fields are positioned are continuous;
judging whether the test statement in which the input fields are located has a content field or not under the condition that the at least two input fields exist and the test statement in which the at least two input fields are located is continuous; and
and under the condition that the content field exists in the test statement in which the input field is located, determining that the test statement in which the input field is located is of a first type of invalidity.
6. The method of claim 5, wherein the invalidity type further includes a second invalidity type,
the optimizing the statement to be optimized based on the preset optimizing rule corresponding to the optimizing type further comprises:
judging whether click fields exist in the test sentences;
judging whether a text box field exists in the test statement in which the click field exists or judging whether click coordinates exist in the test statement in which the click field exists or not under the condition that whether the click field exists in the plurality of test statements;
determining that the sentence to be optimized, in which the click field is located, is of a second invalidity type when the text box field exists in the test sentence in which the click field is located or when the click coordinate exists in the test sentence in which the click field is located; or alternatively
Judging whether a drag field exists in the plurality of test sentences;
and under the condition that a drag field exists in the plurality of test sentences, determining that the sentence to be optimized where the drag field exists is of a second invalidity type.
7. The method of claim 6, wherein the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type comprises:
for the first invalidity type, reserving the last test statement in at least two test statements corresponding to the first invalidity type; and
and deleting the test statement of the second invalidity type for the second invalidity type.
8. The method of claim 1, wherein the optimization type comprises a merger type,
the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type comprises the following steps:
judging whether at least two continuous test sentences contain the same selection field or not in the plurality of test sentences; and
and under the condition that at least two continuous test sentences contain the same selection field in the plurality of test sentences, determining that the sentence to be optimized where the selection field is located is the mergence type.
9. The method of claim 8, wherein the optimizing the statement to be optimized based on the preset optimization rule corresponding to the optimization type comprises:
and merging the at least two continuous test sentences into one test sentence for the mergence type.
10. A test code optimization apparatus comprising:
the system comprises an acquisition module, a recording module and a processing module, wherein the acquisition module is used for acquiring test script codes, the test script codes comprise a plurality of test sentences, the test sentences comprise a plurality of fields, and the plurality of test sentences are formed by recording manual test operation;
the recognition module is used for recognizing the plurality of test sentences according to a preset recognition rule, and screening sentences to be optimized, wherein the sentences to be optimized are formed based on redundant operation in manual test operation, and the sentences to be optimized comprise a plurality of optimization types; and
and the optimizing module is used for optimizing the statement to be optimized based on a preset optimizing rule corresponding to the optimizing type.
11. 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 any of claims 1-9.
12. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any of claims 1 to 9.
13. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 9.
CN202310079152.4A 2023-01-18 2023-01-18 Test code optimization method, apparatus, device, medium and program product Pending CN116627792A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310079152.4A CN116627792A (en) 2023-01-18 2023-01-18 Test code optimization method, apparatus, device, medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310079152.4A CN116627792A (en) 2023-01-18 2023-01-18 Test code optimization method, apparatus, device, medium and program product

Publications (1)

Publication Number Publication Date
CN116627792A true CN116627792A (en) 2023-08-22

Family

ID=87590801

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310079152.4A Pending CN116627792A (en) 2023-01-18 2023-01-18 Test code optimization method, apparatus, device, medium and program product

Country Status (1)

Country Link
CN (1) CN116627792A (en)

Similar Documents

Publication Publication Date Title
AU2014400621B2 (en) System and method for providing contextual analytics data
US20200225927A1 (en) Methods and systems for automating computer application tasks using application guides, markups and computer vision
CN113344523A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN113515271B (en) Service code generation method and device, electronic equipment and readable storage medium
WO2023151397A1 (en) Application program deployment method and apparatus, device, and medium
CN115760013A (en) Operation and maintenance model construction method and device, electronic equipment and storage medium
CN116627792A (en) Test code optimization method, apparatus, device, medium and program product
CN113032256B (en) Automated testing method, apparatus, computer system, and readable storage medium
CN114707961A (en) Pending task execution method, device, equipment, medium and program product based on approval flow configuration
CN116467156A (en) Joint debugging test method and device, storage medium and electronic equipment
CN114490130A (en) Message subscription method and device, electronic equipment and storage medium
CN114371884A (en) Method, device, equipment and storage medium for processing Flink calculation task
CN114240392A (en) Information processing method, task approval method, and information processing apparatus
CN113918525A (en) Data exchange scheduling method, system, electronic device, medium, and program product
CN113487224A (en) Content processing method, apparatus, device, medium, and program product
CN111949259A (en) Risk decision configuration method, system, electronic equipment and storage medium
US11507728B2 (en) Click to document
CN117435464A (en) Software testing method and device, electronic equipment and computer readable storage medium
CN118170961A (en) Cloud native environment information processing method, device, equipment, storage medium and program product
CN116436771A (en) Request response method, device, equipment and storage medium
CN113392014A (en) Test case generation method and device, electronic equipment and medium
CN115086212A (en) Webpage testing method and device
CN117194250A (en) Test case generation method, device, equipment, medium and program product
CN118093698A (en) Data processing method, device, electronic equipment and computer storage medium
CN116561635A (en) Training method, device and equipment for fault detection model under micro-service architecture

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