CN112749083A - Test script generation method and device - Google Patents

Test script generation method and device Download PDF

Info

Publication number
CN112749083A
CN112749083A CN202011434671.0A CN202011434671A CN112749083A CN 112749083 A CN112749083 A CN 112749083A CN 202011434671 A CN202011434671 A CN 202011434671A CN 112749083 A CN112749083 A CN 112749083A
Authority
CN
China
Prior art keywords
script
test
test script
statement
conversion rule
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
CN202011434671.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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202011434671.0A priority Critical patent/CN112749083A/en
Publication of CN112749083A publication Critical patent/CN112749083A/en
Pending legal-status Critical Current

Links

Images

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/3688Test management for test execution, e.g. scheduling of test suites

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)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a test script generation method and device, which can firstly obtain a test script obtained by recording a test operation by a script generation tool. The test script can be analyzed, and the identification of a script generation tool for generating the test script is determined; then, determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generation tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generation tool and the target conversion rule; after the target conversion rule is determined, the grammar of the first test script can be converted by using the target conversion rule corresponding to the first test script, so that a second test script is obtained. Therefore, even if the test script generated by the script generation tool is incompatible with the test software, the test script can be converted into the test script meeting the requirements of the test software through the target conversion rule without being manually written by a tester, and the working pressure of the tester is reduced.

Description

Test script generation method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a test script generation method and apparatus.
Background
With the development of computer technology, software tends to be large-sized, complicated, and integrated. In order to ensure that the quality of the software meets the requirements, the software can be tested before being on-line. During the testing process, the testing software can be used for simulating the actual running process of the tested software, so as to check whether the software can meet the specified requirements or figure out the difference between the expected result and the actual result, and a technician can optimize the software with problems.
In the traditional technology, most technicians manually write test scripts, so that the efficiency is low. To solve this problem, screen recording software may be used to convert the user's actions into test scripts. The screen recording software can record the operation of the user on the screen to the software and convert the operation of the user into the test script to obtain the test script.
However, the format of the test script generated by the screen recording software is often preset by the designer of the screen recording software. The test script generated by the screen recording software is incompatible with the test software, so that the test software cannot utilize the generated test script for testing, and a tester still needs to manually write the test script.
Disclosure of Invention
In view of this, embodiments of the present application provide a method and an apparatus for generating a test script, which aim to convert a test script generated by a script generation tool into a test script meeting syntax requirements.
In a first aspect, an embodiment of the present application provides a method for generating a test script, where the method includes:
acquiring a first test script, wherein the first test script is generated by recording a test operation through a script generation tool;
analyzing the first test script to obtain an identifier of the script generation tool;
determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generation tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generation tool and the target conversion rule;
and converting the grammar of the first test script by using a target conversion rule corresponding to the first test script to obtain a second test script.
Optionally, the corresponding relationship includes a corresponding relationship between an identifier of the script generation tool, an identifier of the development framework, and the target conversion rule;
the determining the target conversion rule of the first test script according to the identifier and the corresponding relation of the script generation tool comprises:
analyzing the test script to obtain an identifier of a development framework corresponding to the test script, wherein the development framework is adopted by an operation object of the test operation;
and determining the target conversion rule of the first test script according to the identification of the script generation tool, the identification of the development framework and the corresponding relation.
Optionally, the target conversion rule includes a key information extraction rule, and the key information extraction rule includes an identifier of at least one type of key information;
the converting the first test script using the target conversion rule includes:
reading a script statement of the first test script;
judging whether the script statement comprises the identification of the key information;
and in response to the script statement comprising the identification of any one of the at least one piece of key information, extracting the key information.
Optionally, the target conversion rule includes an operation conversion rule, the operation conversion rule is used for converting an operation statement meeting the syntax rule of the first test script into an operation statement meeting the syntax rule of the second test script, and the operation statement includes at least one operation action;
the converting the test script using the target conversion rule includes:
reading a script statement of the first test script;
judging whether the script statement comprises an operation action or not;
and in response to the script statement comprising an operation action, converting the script statement into an operation statement which conforms to the grammar rule of the second test script by using the operation conversion rule.
Optionally, the target conversion rule includes an object conversion rule, where the object conversion rule is used to convert an object statement that conforms to the syntax rule of the first test script into an object statement that conforms to the syntax rule of the second test script, where the object statement includes at least one operation object, and the operation object is an object for executing the test operation;
the converting the test script using the target conversion rule includes:
reading a script statement of the test script;
judging whether the script statement comprises an operation object or not;
and in response to the statement type comprising an operation object, converting the script statement into an object statement conforming to the grammar rule of the second test script by using the object conversion rule.
Optionally, the method further comprises:
extracting an operation object of the object statement;
in response to a storage space not including the operand, storing the operand to the storage space.
Optionally, the target transformation rule comprises a first transformation rule and a second transformation rule; the first conversion rule is used for converting the test script into the test case, and the second conversion rule is used for converting the test case into the test script;
the converting the syntax of the first test script using the target conversion rule corresponding to the first test script includes:
converting the first test script into a test case by using the first conversion rule;
and responding to a test case calling instruction, and converting the test case into the second test script by using the second conversion rule.
In a second aspect, an embodiment of the present application provides a test script generating apparatus, where the apparatus includes:
the acquisition module is used for acquiring a first test script, and the first test script is generated by recording a test operation through a script generation tool;
the analysis module is used for analyzing the first test script to obtain the identification of the script generation tool;
the determining module is used for determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generating tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generating tool and the target conversion rule;
and the conversion module is used for converting the grammar of the first test script by using the target conversion rule corresponding to the first test script to obtain a second test script.
Optionally, the corresponding relationship includes a corresponding relationship between an identifier of the script generation tool, an identifier of the development framework, and the target conversion rule;
the determining module is configured to analyze the test script to obtain an identifier of a development framework corresponding to the test script, where the development framework is a development framework adopted by an operation object of the test operation; and determining the target conversion rule of the first test script according to the identification of the script generation tool, the identification of the development framework and the corresponding relation.
Optionally, the target conversion rule includes an operation conversion rule, and the operation conversion rule is used to convert an operation statement that conforms to the syntax rule of the first test script into an operation statement that conforms to the syntax rule of the second test script, where the operation statement includes at least one operation action. The conversion module is used for reading the script statement of the first test script; judging whether the script statement comprises an operation action or not; and in response to the script statement comprising an operation action, converting the script statement into an operation statement which conforms to the grammar rule of the second test script by using the operation conversion rule.
Optionally, the target conversion rule includes an object conversion rule, and the object conversion rule is configured to convert an object statement that conforms to the syntax rule of the first test script into an object statement that conforms to the syntax rule of the second test script, where the object statement includes at least one operation object, and the operation object is an object for executing the test operation. The conversion module is used for reading script statements of the test script; judging whether the script statement comprises an operation object or not; and in response to the statement type comprising an operation object, converting the script statement into an object statement conforming to the grammar rule of the second test script by using the object conversion rule.
Optionally, the target conversion rule includes a key information extraction rule, and the key information extraction rule includes an identifier of at least one type of key information;
the conversion module is used for reading the script statement of the first test script; judging whether the script statement comprises the identification of the key information; and in response to the script statement comprising the identification of any one of the at least one piece of key information, extracting the key information.
Optionally, the target conversion rule includes an object conversion rule, the object conversion rule is used for converting an object statement conforming to the syntax rule of the first test script into an object statement conforming to the syntax rule of the second test script, and the object statement includes at least one operation object; the device also comprises a storage module;
the storage module is used for extracting an operation object of the object statement; in response to a storage space not including the operand, storing the operand to the storage space.
The embodiment of the application provides a test script generation method and device, and when a second test script with a unified format is generated, a test script obtained by recording a test operation by a script generation tool can be obtained first. Then, the test script can be analyzed, and the identification of a script generation tool for generating the test script is determined; then, determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generation tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generation tool and the target conversion rule; after the target conversion rule is determined, the grammar of the first test script can be converted by using the target conversion rule corresponding to the first test script, so that a second test script is obtained. In this way, by analyzing the test script, it is possible to determine which script generation tool the test script is generated by, and select the target conversion rule corresponding to the script generation tool that generates the test script. According to the target conversion rule, the grammar of the test script generated by the script generation tool can be converted into the test script which accords with the rule of the test software. Therefore, even if the test script generated by the script generation tool is incompatible with the test software, the test script can be converted into the test script meeting the requirements of the test software through the target conversion rule, so that the test software can record the generated test script by using the script generation tool without being manually written by a tester, and the working pressure of the tester is reduced.
Drawings
To illustrate the technical solutions in the present embodiment or the prior art more clearly, the drawings needed to be used in the description of the embodiment or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flowchart of a method for generating a test script according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of a test script generating apparatus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of another test script generating apparatus according to an embodiment of the present application.
Detailed Description
Currently, a script generation tool may record a user's operation and convert the user's operation into a test script. Specifically, the script generation tool may determine an operation object operated by the user, and record specific operations such as mouse movement, click, or keyboard input of the user. And converting the operations and the corresponding operation objects into test scripts. Therefore, when the test software runs the test script, the test script can simulate the operation of a user and input the operation of the user into the test software to realize automatic test.
However, the syntax of the test script generated by the script generation tool is set by the software developer of the script generation tool, and the syntax of the test software is set by the software developer of the test software. Therefore, in practical applications, grammars of the test generation tool and the test software may not be matched, the test software cannot directly utilize the test script generated by the script generation tool, and technicians are required to manually write the test script, or manually rewrite the test script generated by the script generation tool into the test script meeting grammatical rules of the test software, so that the working pressure of the testers is increased.
In addition, many of the existing script generation tools can generate a test script only for specific software. Therefore, when a large network system composed of a plurality of modules is tested, operations of different modules often need to be recorded by using different script generation tools. The grammar rules of the test scripts generated by different script generation tools are often different, and the test scripts generated by different script generation tools cannot be run by using uniform test software.
In order to provide a method capable of converting a test script generated by a script generation tool into a test script meeting the grammatical requirements of test software, the embodiment of the application provides a test script generation method and device. The file uploading method provided by the embodiment of the application is described from the perspective of a test platform by combining with the drawings of the specification. It should be noted that the test platform may be a software platform running on a server, or may also be a software module of test software, which is not limited in this embodiment of the present application. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart of a method of generating a test script according to an embodiment of the present application, including:
s101: a first test script is obtained.
When the test script is generated, the test operation of a tester can be recorded by using a script generation tool to obtain a first test script. The script generation tool may be any software used for recording a test script obtained by a user operation, such as Unified Functional Testing software, Selenium software, or Katalon software. The technical personnel can test the software to be tested, and the script generation tool records the test operation of the technical personnel to obtain a first test script.
In this embodiment of the application, the test platform may obtain the first test script when the script generation tool generates the first test script, or may obtain a plurality of first test scripts after a plurality of first test scripts are generated.
S102: and analyzing the first test script to obtain the identifier of the script generation tool.
After the first test script is obtained, the test platform may analyze the first test script to obtain an identifier of a script generation tool that generates the first test script. Specifically, the test platform may obtain one or more test statements of the first test script, analyze syntax rules of the one or more test statements, determine syntax rules corresponding to the first test script to which the test statements belong, and determine the identifier of the script generation tool according to the syntax rules corresponding to the test scripts.
S103: and determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generation tool.
After obtaining the identifier of the script generation tool corresponding to the first test script, the test platform may determine the target conversion rule corresponding to the first test script according to the identifier and the corresponding relationship of the script generation tool. The corresponding relationship may include a corresponding relationship between an identifier of the script generation tool and the target conversion rule. According to the corresponding relationship, the test platform may determine the target conversion rule corresponding to the identifier of the script generation tool as the target conversion rule corresponding to the first test script.
In consideration of the fact that the development frameworks of the tested software are different in the actual application scenario, the grammar rules of the obtained test scripts are also different, that is, the grammar rules of the test scripts generated by the same script generation tool for the tested software under different development frameworks may also be different. In view of this problem, in the embodiment of the present application, the foregoing corresponding relationship may further include a corresponding relationship between an identifier of the script generation tool, an identifier of the development framework, and the target conversion rule.
Correspondingly, when the target generation rule is determined, the test platform can analyze the test script, so as to determine the identifier of the development framework corresponding to the test script. The development framework is adopted by an operation object of the test operation, namely the development framework adopted by the tested software. After the development framework is determined, the test platform may select the target conversion rule corresponding to the first test script from the correspondence according to the identifier of the script generation tool corresponding to the first test script and the identifier of the development framework. Optionally, the test platform may determine, according to the identifier of the script generation tool corresponding to the first test script, a conversion rule set corresponding to the script generation tool from the at least one conversion rule, and then select the target conversion rule from the conversion rule set according to the identifier of the development framework.
S104: and converting the grammar of the first test script by using a target conversion rule corresponding to the first test script to obtain a second test script.
After the target conversion rule corresponding to the first test script is determined, the test platform may perform syntax conversion on the first test script according to the target conversion rule to obtain a second test script meeting the requirement of the test software.
In some possible implementations, the target transformation rule may include a key information extraction rule, which is used to extract the key information in the first test script, and may include an identifier of at least one type of key information, such as a Uniform Resource Locator (URL). Accordingly, when the first test script is converted by the target conversion rule, the test platform may read a script statement of the first test script, which may be, for example, a statement of a first line of the first test script. Then, the test platform can judge whether the script statement comprises any one of the identifications of at least one kind of key information. If the script statement comprises the identification of the key information, the script statement is shown to carry the key information, and the test platform can extract the key information corresponding to the identification of the key information in the script statement.
In some possible implementations, the target transformation rule may include an operational transformation rule. The operation conversion rule is used for converting the operation statement which accords with the grammar rule of the first test script into the operation statement which accords with the grammar rule of the second test script. The operation statement comprises at least one operation action, namely the operation of the technician on the tested software. Accordingly, when the first test script is converted by the target conversion rule, the test platform may read a script statement of the first test script. And determines whether the script statement includes an operation action. If the script statement comprises the operation action, the script statement is stated to be used for describing the operation action, and the test platform can convert the script statement into an object statement which accords with the grammar rule of the second test script according to the operation conversion rule.
In some possible implementations, the target transformation rules may include object transformation rules. The operation conversion rule is used for converting the object statement which accords with the grammar rule of the first test script into the object statement which accords with the grammar rule of the second test script. The object statement comprises at least one operation object, namely an object operated by a technician when the technician operates the software to be tested. Accordingly, when the first test script is converted by the target conversion rule, the test platform may read a script statement of the first test script. And judges whether the script statement includes an operation object. If the script statement comprises the operation object, the script statement is used for describing the operation object, and the test platform can convert the script statement into the object statement which accords with the grammar rule of the second test script according to the object conversion rule.
Optionally, after the script statement is converted into the object statement meeting the syntax rule of the second test script, the test platform may further extract the operation object of the object statement and determine whether the operation object is stored in the storage space. If the storage space does not include the operation object, the test platform may store the operation object in the storage space. If the operation object is included in the storage space, the test platform may discard the operation object. The storage space may be, for example, a storage space corresponding to a hard disk of a server. Therefore, after the first test script is converted, all the operation objects in the first test script are stored in the storage space, and technicians can check the operation objects.
In an actual application scenario, for convenience of management, the first test script may be converted into a test case for storage, and when the software to be tested needs to be tested, the test case is converted into a second test script. Therefore, the test case can be directly maintained when the test case is maintained, and the script is not required to be maintained. Accordingly, the target transformation rule may include a first transformation rule and a second transformation rule. The test platform can convert the first test script into a test case by using the first conversion rule, and store the test case into the test case library so as to maintain the test case. Alternatively, the test case may describe the operation in a natural language format. . When the software to be tested needs to be tested, the test platform can convert the test case into a second test script by using a second conversion rule.
The embodiment of the application provides a test script generation method, and when a second test script with a unified format is generated, a test script obtained by recording a test operation by a script generation tool can be obtained first. Then, the test script can be analyzed, and the identification of a script generation tool for generating the test script is determined; then, determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generation tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generation tool and the target conversion rule; after the target conversion rule is determined, the grammar of the first test script can be converted by using the target conversion rule corresponding to the first test script, so that a second test script is obtained. In this way, by analyzing the test script, it is possible to determine which script generation tool the test script is generated by, and select the target conversion rule corresponding to the script generation tool that generates the test script. According to the target conversion rule, the grammar of the test script generated by the script generation tool can be converted into the test script which accords with the rule of the test software. Therefore, even if the test script generated by the script generation tool is incompatible with the test software, the test script can be converted into the test script meeting the requirements of the test software through the target conversion rule, so that the test software can record the generated test script by using the script generation tool without being manually written by a tester, and the working pressure of the tester is reduced.
The foregoing provides some specific implementation manners of the test case generation method for the embodiments of the present application, and based on this, the present application also provides a corresponding apparatus. The above-mentioned device provided by the embodiments of the present application will be described in terms of functional modularity.
Referring to fig. 2, a schematic structural diagram of a test case generating apparatus 200 includes:
the obtaining module 210 is configured to obtain a first test script, where the first test script is generated by recording a test operation through a script generation tool.
And the analysis module 220 is configured to analyze the first test script to obtain an identifier of the script generation tool.
The determining module 230 is configured to determine a target conversion rule corresponding to the first test script according to an identifier of the script generation tool and a corresponding relationship, where the corresponding relationship includes a corresponding relationship between the identifier of the script generation tool and the target conversion rule.
The conversion module 240 is configured to convert the syntax of the first test script by using a target conversion rule corresponding to the first test script to obtain a second test script.
The embodiment of the application provides a test script generating device, and when a second test script with a unified format is generated, a test script obtained by recording a test operation by a script generating tool can be obtained first. Then, the test script can be analyzed, and the identification of a script generation tool for generating the test script is determined; then, determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generation tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generation tool and the target conversion rule; after the target conversion rule is determined, the grammar of the first test script can be converted by using the target conversion rule corresponding to the first test script, so that a second test script is obtained. In this way, by analyzing the test script, it is possible to determine which script generation tool the test script is generated by, and select the target conversion rule corresponding to the script generation tool that generates the test script. According to the target conversion rule, the grammar of the test script generated by the script generation tool can be converted into the test script which accords with the rule of the test software. Therefore, even if the test script generated by the script generation tool is incompatible with the test software, the test script can be converted into the test script meeting the requirements of the test software through the target conversion rule, so that the test software can record the generated test script by using the script generation tool without being manually written by a tester, and the working pressure of the tester is reduced.
Optionally, in some possible implementations, the correspondence includes a correspondence between an identifier of the script generation tool, an identifier of the development framework, and the target conversion rule.
The determining module 230 is configured to analyze the test script to obtain an identifier of a development frame corresponding to the test script, where the development frame is a development frame adopted by an operation object of the test operation; and determining the target conversion rule of the first test script according to the identification of the script generation tool, the identification of the development framework and the corresponding relation.
Optionally, in some possible implementations, the target transformation rule includes a key information extraction rule, and the key information extraction rule includes an identifier of at least one type of key information.
The conversion module 240 is configured to read a script statement of the first test script; judging whether the script statement comprises the identification of the key information; and in response to the script statement comprising the identification of any one of the at least one piece of key information, extracting the key information.
Optionally, in some possible implementations, the target conversion rule includes an operation conversion rule, and the operation conversion rule is used to convert an operation statement that conforms to the syntax rule of the first test script into an operation statement that conforms to the syntax rule of the second test script, where the operation statement includes at least one operation action.
The conversion module 240 is configured to read a script statement of the first test script; judging whether the script statement comprises an operation action or not; and in response to the script statement comprising an operation action, converting the script statement into an operation statement which conforms to the grammar rule of the second test script by using the operation conversion rule.
Optionally, in some possible implementations, the target conversion rule includes an object conversion rule, and the object conversion rule is used to convert an object statement that conforms to the syntax rule of the first test script into an object statement that conforms to the syntax rule of the second test script, where the object statement includes at least one operation object, and the operation object is an object for executing the test operation.
The conversion module 240 is configured to read a script statement of the test script; judging whether the script statement comprises an operation object or not; and in response to the statement type comprising an operation object, converting the script statement into an object statement conforming to the grammar rule of the second test script by using the object conversion rule.
Optionally, referring to fig. 3, on the basis of the apparatus shown in fig. 2, the target conversion rule includes an object conversion rule, where the object conversion rule is used to convert an object statement that conforms to the syntax rule of the first test script into an object statement that conforms to the syntax rule of the second test script, and the object statement includes at least one operation object; the apparatus 200 further comprises a storage module 250;
the storage module 250 is configured to extract an operation object of the object statement; in response to a storage space not including the operand, storing the operand to the storage space.
In the embodiments of the present application, the names "first" and "second" in the names "first test script", "second test script", and the like are used only for name identification, and do not represent the first and second in sequence.
As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the above embodiment methods can be implemented by software plus a general hardware platform. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a storage medium, such as a read-only memory (ROM)/RAM, a magnetic disk, an optical disk, or the like, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network communication device such as a router) to execute the method according to the embodiments or some parts of the embodiments of the present application.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The above description is only an exemplary embodiment of the present application, and is not intended to limit the scope of the present application.

Claims (10)

1. A method for generating a test script, the method comprising:
acquiring a first test script, wherein the first test script is generated by recording a test operation through a script generation tool;
analyzing the first test script to obtain an identifier of the script generation tool;
determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generation tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generation tool and the target conversion rule;
and converting the grammar of the first test script by using a target conversion rule corresponding to the first test script to obtain a second test script.
2. The method of claim 1, wherein the correspondence comprises a correspondence of an identifier of the script generation tool, an identifier of a development framework, and the target transformation rule;
the determining the target conversion rule of the first test script according to the identifier and the corresponding relation of the script generation tool comprises:
analyzing the test script to obtain an identifier of a development framework corresponding to the test script, wherein the development framework is adopted by an operation object of the test operation;
and determining the target conversion rule of the first test script according to the identification of the script generation tool, the identification of the development framework and the corresponding relation.
3. The method of claim 1, wherein the target transformation rule comprises a key information extraction rule comprising an identification of at least one key information;
the converting the first test script using the target conversion rule includes:
reading a script statement of the first test script;
judging whether the script statement comprises the identification of the key information;
and in response to the script statement comprising the identification of any one of the at least one piece of key information, extracting the key information.
4. The method according to claim 1, wherein the target conversion rule comprises an operation conversion rule for converting an operation statement conforming to the grammatical rule of the first test script into an operation statement conforming to the grammatical rule of the second test script, the operation statement comprising at least one operation action;
the converting the test script using the target conversion rule includes:
reading a script statement of the first test script;
judging whether the script statement comprises an operation action or not;
and in response to the script statement comprising an operation action, converting the script statement into an operation statement which conforms to the grammar rule of the second test script by using the operation conversion rule.
5. The method according to claim 1, wherein the target conversion rule comprises an object conversion rule for converting an object statement conforming to the syntax rule of the first test script into an object statement conforming to the syntax rule of the second test script, the object statement comprising at least one operation object, the operation object being an object for execution of the test operation;
the converting the test script using the target conversion rule includes:
reading a script statement of the test script;
judging whether the script statement comprises an operation object or not;
and in response to the statement type comprising an operation object, converting the script statement into an object statement conforming to the grammar rule of the second test script by using the object conversion rule.
6. The method of claim 5, further comprising:
extracting an operation object of the object statement;
in response to a storage space not including the operand, storing the operand to the storage space.
7. The method of claim 1, wherein the target transformation rule comprises a first transformation rule and a second transformation rule; the first conversion rule is used for converting the test script into the test case, and the second conversion rule is used for converting the test case into the test script;
the converting the syntax of the first test script using the target conversion rule corresponding to the first test script includes:
converting the first test script into a test case by using the first conversion rule;
and responding to a test case calling instruction, and converting the test case into the second test script by using the second conversion rule.
8. An apparatus for generating a test script, the apparatus comprising:
the acquisition module is used for acquiring a first test script, and the first test script is generated by recording a test operation through a script generation tool;
the analysis module is used for analyzing the first test script to obtain the identification of the script generation tool;
the determining module is used for determining a target conversion rule corresponding to the first test script according to the identification and the corresponding relation of the script generating tool, wherein the corresponding relation comprises the corresponding relation between the identification of the script generating tool and the target conversion rule;
and the conversion module is used for converting the grammar of the first test script by using the target conversion rule corresponding to the first test script to obtain a second test script.
9. The apparatus according to claim 8, wherein the correspondence includes a correspondence between an identifier of the script generation tool, an identifier of a development framework, and the target transformation rule;
the determining module is configured to analyze the test script to obtain an identifier of a development framework corresponding to the test script, where the development framework is a development framework adopted by an operation object of the test operation; and determining the target conversion rule of the first test script according to the identification of the script generation tool, the identification of the development framework and the corresponding relation.
10. The apparatus of claim 8, wherein the target transformation rule comprises a key information extraction rule comprising an identification of at least one key information;
the conversion module is used for reading the script statement of the first test script; judging whether the script statement comprises the identification of the key information; and in response to the script statement comprising the identification of any one of the at least one piece of key information, extracting the key information.
CN202011434671.0A 2020-12-10 2020-12-10 Test script generation method and device Pending CN112749083A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011434671.0A CN112749083A (en) 2020-12-10 2020-12-10 Test script generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011434671.0A CN112749083A (en) 2020-12-10 2020-12-10 Test script generation method and device

Publications (1)

Publication Number Publication Date
CN112749083A true CN112749083A (en) 2021-05-04

Family

ID=75649146

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011434671.0A Pending CN112749083A (en) 2020-12-10 2020-12-10 Test script generation method and device

Country Status (1)

Country Link
CN (1) CN112749083A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821436A (en) * 2021-09-23 2021-12-21 北京天融信网络安全技术有限公司 Test script generation method and device
CN116009836A (en) * 2022-12-28 2023-04-25 苏州峰之鼎信息科技有限公司 RPA programming method, device, equipment and storage medium based on script language
CN117609060A (en) * 2023-12-01 2024-02-27 上海鱼尔网络科技有限公司 Recording script generation method, device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106874208A (en) * 2017-02-27 2017-06-20 网易(杭州)网络有限公司 The processing method of test script, device and electronic equipment
CN108415826A (en) * 2018-01-12 2018-08-17 深圳壹账通智能科技有限公司 Test method, terminal device and the computer readable storage medium of application
CN109062816A (en) * 2018-10-12 2018-12-21 广东电网有限责任公司 A kind of method, device and equipment of software test
CN109684195A (en) * 2018-10-26 2019-04-26 平安科技(深圳)有限公司 Electronic device, script conversion method and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106874208A (en) * 2017-02-27 2017-06-20 网易(杭州)网络有限公司 The processing method of test script, device and electronic equipment
CN108415826A (en) * 2018-01-12 2018-08-17 深圳壹账通智能科技有限公司 Test method, terminal device and the computer readable storage medium of application
CN109062816A (en) * 2018-10-12 2018-12-21 广东电网有限责任公司 A kind of method, device and equipment of software test
CN109684195A (en) * 2018-10-26 2019-04-26 平安科技(深圳)有限公司 Electronic device, script conversion method and storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821436A (en) * 2021-09-23 2021-12-21 北京天融信网络安全技术有限公司 Test script generation method and device
CN113821436B (en) * 2021-09-23 2023-08-29 北京天融信网络安全技术有限公司 Method and device for generating test script
CN116009836A (en) * 2022-12-28 2023-04-25 苏州峰之鼎信息科技有限公司 RPA programming method, device, equipment and storage medium based on script language
CN116009836B (en) * 2022-12-28 2024-04-30 苏州峰之鼎信息科技有限公司 RPA programming method, device, equipment and storage medium based on script language
CN117609060A (en) * 2023-12-01 2024-02-27 上海鱼尔网络科技有限公司 Recording script generation method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110309071B (en) Test code generation method and module, and test method and system
CN112749083A (en) Test script generation method and device
CN110825618B (en) Method and related device for generating test case
CN103164328A (en) Method and device and system for regression testing of service function
US11074162B2 (en) System and a method for automated script generation for application testing
CN101996131A (en) Automatic test method and automatic test platform for graphic user interface (GUI) based on x extensive makeup language (XML) packaging key word
CN112732576B (en) Automatic testing method, device and equipment based on user interface
CN103729294A (en) Method and device for testing performance script of application software
GB2587432A (en) System and method for software architecture redesign
CN102479152A (en) Method and device for obtaining tool automatic test results on basis of Android platform
CN106778264A (en) The application program analysis method and analysis system of a kind of mobile client
CN115658529A (en) Automatic testing method for user page and related equipment
CN113448845A (en) UI automation test method and system
CN113505082A (en) Application program testing method and device
CN105760300A (en) Automatic STK/UTK service testing method and system
CN117421217A (en) Automatic software function test method, system, terminal and medium
CN113836014A (en) Interface testing method and device, electronic equipment and storage medium
CN111506305A (en) Tool kit generation method and device, computer equipment and readable storage medium
CN116383025A (en) Performance test method, device, equipment and medium based on Jmeter
CN116719736A (en) Test case generation method and device for testing software interface
CN111400171A (en) Interface testing method, system, device and readable storage medium
CN110795338B (en) Front-end and back-end interaction-based automatic testing method and device and electronic equipment
CN114064469A (en) Interface automation test method and storage medium
Fernández-Ropero et al. Repairing business process models as retrieved from source code
CN113157556A (en) Industry building software defect management method based on selected principal component identification

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