CN115543831A - Test script generation method, device, equipment and storage medium - Google Patents

Test script generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN115543831A
CN115543831A CN202211288926.6A CN202211288926A CN115543831A CN 115543831 A CN115543831 A CN 115543831A CN 202211288926 A CN202211288926 A CN 202211288926A CN 115543831 A CN115543831 A CN 115543831A
Authority
CN
China
Prior art keywords
sub
execution
statement
data
test
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
CN202211288926.6A
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.)
Nfs China Software Co ltd
Original Assignee
Nfs China Software Co ltd
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 Nfs China Software Co ltd filed Critical Nfs China Software Co ltd
Priority to CN202211288926.6A priority Critical patent/CN115543831A/en
Publication of CN115543831A publication Critical patent/CN115543831A/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

Abstract

The application discloses a test script generation method, a test script generation device, test script generation equipment and a storage medium, which are applied to the technical field of testing. The method comprises the steps of responding to a trigger operation aiming at a recording key, monitoring an execution operation executed by input equipment aiming at target software, and acquiring test data corresponding to the execution operation; acquiring script operation dependent statements; analyzing the test data to obtain an operation parameter value of each sub-operation, and respectively assigning values to parameter variables included in a preset function by using the operation parameter value of each sub-operation to obtain an execution statement of each sub-operation; and generating a test script comprising the script dependency statements and the execution statements of each sub-operation according to the script operation dependency statements and the execution statements of each sub-operation. Therefore, the execution statements for executing each sub-operation can be automatically generated based on the script operation dependent statements, a tester does not need to manually write the test script, and the efficiency of generating the test script is improved.

Description

Test script generation method, device, equipment and storage medium
Technical Field
The present application relates to the field of test technologies, and in particular, to a method, an apparatus, a device, and a storage medium for generating a test script.
Background
Software testing is an important process for testers to detect software performance. And (4) designing test contents according to the functions of the software by a tester, testing the test contents and confirming whether the functions of the software can normally run or not.
Currently, a tester needs to write a test script according to test contents. And the software is run by loading the test script, so that the software is tested. The process of compiling the test script by the tester is complicated, so that the software testing efficiency is low.
Disclosure of Invention
In view of this, the present application provides a method, an apparatus, a device and a storage medium for generating a test script, which can improve the efficiency of generating the test script.
In order to solve the above problems, the technical solution provided by the present application is as follows:
in a first aspect, the present application provides a test script generating method, where the method includes:
responding to a trigger operation aiming at a recording key, monitoring an execution operation executed by input equipment aiming at target software, and acquiring test data corresponding to the execution operation; the execution operation comprises at least one sub-operation; the test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations, wherein each sub-operation in the execution operation aims at;
acquiring a script operation dependent statement; the script operation dependent statement is used for defining a preset function and parameter variables included by the preset function; the preset function comprises a positioning function and an operation function, the positioning function comprises a position variable, and the operation function comprises an action variable;
analyzing the test data to obtain an operation parameter value of each sub-operation; the operating parameters comprise action parameters and position parameters;
assigning values to parameter variables included in the preset function respectively by using the operation parameter values of each sub-operation to obtain an execution statement of each sub-operation;
and generating a test script according to the script operation dependent statement and the execution statement of each sub-operation, wherein the execution sequence of the execution statement of each sub-operation is determined according to the execution sequence among the sub-operations in the test data.
In a possible implementation manner, the test data is recorded in a first data table, each line of test data included in the first data table corresponds to one sub-operation, and the sequence of the lines of test data in the first data table corresponds to the execution sequence between the sub-operations;
the analyzing the test data to obtain an operation parameter value of each sub-operation includes:
analyzing the test data included in the first data table line by line in sequence, determining action parameter values corresponding to the operation parameters of the sub-operations according to the operation objects and the operation action types which are aimed at by the sub-operations corresponding to each line of test data, and determining position parameter values corresponding to the operation parameters of the sub-operations according to the operation positions of the sub-operations corresponding to each line of test data to obtain a first operation parameter table;
each line of data included in the first operation parameter table corresponds to one sub-operation, and each line of data includes an action parameter value and a position parameter value of the sub-operation; the row order of each row of data included in the first operation parameter list corresponds to an execution order among the respective sub-operations.
In a possible implementation manner, the assigning, by using the operation parameter value of each sub-operation, the parameter variable included in the preset function to obtain the execution statement of each sub-operation includes:
assigning the action variable of the operation function by using the action parameter value of the sub-operation included in the first target data to obtain an action statement of the sub-operation corresponding to the first target data, wherein the action statement is composed of the operation function including the assigned action variable; the first target data is a row of data included in the first operation parameter table;
and assigning a value to the position variable of the positioning function by using the position parameter value of the sub-operation included in the first target data to obtain a position statement of the sub-operation corresponding to the first target data, wherein the position statement is composed of the positioning function including the assigned position variable.
In a possible implementation manner, the test data further includes an execution interval duration between two sub-operations adjacent to each other in the execution sequence; the preset function further comprises an interval duration function, and the interval duration function comprises a duration variable; the operating parameters further include an execution interval parameter; the test data are recorded in a second data table, each line of test data in the second data table corresponds to one sub-operation, and the sequence of each line of test data in the second data table corresponds to the execution sequence among the sub-operations;
the analyzing the test data to obtain an operation parameter value of each sub-operation includes:
analyzing the test data included in the second data table line by line in sequence, determining action parameter values corresponding to the operation parameters of the sub-operations according to the operation objects and the operation action types which are aimed at by the sub-operations corresponding to each line of test data, determining position parameter values corresponding to the operation parameters of the sub-operations according to the operation positions of the sub-operations corresponding to each line of test data, and taking the execution interval duration between two sub-operations adjacent to the execution sequence as the execution interval parameter values of the sub-operations to obtain a second operation parameter table;
each row of data included in the second operation parameter table corresponds to one sub-operation, and each row of data includes an action parameter value, a position parameter value and an execution interval parameter value of the sub-operation; the execution interval parameter value is used for indicating the execution interval duration between the sub-operation and the next sub-operation adjacent to the execution sequence; the row order of each row of data included in the second operation parameter table corresponds to an execution order between the respective sub-operations.
In a possible implementation manner, the assigning, by using the operation parameter value of each sub-operation, the parameter variable included in the preset function to obtain the execution statement of each sub-operation includes:
assigning values to the action variables of the operation functions by using the action parameter values of the sub-operations included in the second target data to obtain action statements of the sub-operations corresponding to the second target data, wherein the action statements are composed of the operation functions including the assigned action variables; the second target data is a row of data included in the second operation parameter table;
assigning values to the position variables of the positioning functions by using the position parameter values of the sub-operations included in the second target data to obtain position statements of the sub-operations corresponding to the second target data, wherein the position statements are formed by the positioning functions including the assigned position variables;
and assigning values to the duration variables included in the interval duration function by using the execution interval parameter values of the sub-operations included in the second target data to obtain execution interval statements of the sub-operations corresponding to the second target data, wherein the execution interval statements are composed of the interval duration function including the assigned duration variables.
In a possible implementation manner, the preset function further includes a screen capture function, and the screen capture function includes a storage location variable; the execution statement of each sub-operation also comprises a screen capture statement;
before the running a dependent statement and an execution statement of each sub-operation according to the script and generating a test script, the method further includes:
and assigning values to storage position variables of the screen capture functions by using the target storage positions of the sub-operations to respectively obtain screen capture sentences of the sub-operations, wherein the target storage positions are used for storing the screen capture images obtained by executing the sub-operations, and the screen capture sentences are formed by the screen capture functions comprising the assigned storage position variables.
In a possible implementation manner, the image name of the screenshot image of each sub-operation is determined according to the order in the execution sequence of the sub-operations, the image name of the standard image of each sub-operation is the same as the image name of the screenshot image of the sub-operation, and the standard image of each sub-operation is stored in the target storage location of the sub-operation; the preset function further comprises a comparison function comprising a path variable, the method further comprising:
assigning the target storage position of each sub-operation to the image path to obtain a comparison statement;
the generating a test script according to the script running dependency statement and the execution statement of each sub-operation comprises:
and generating a test script according to the script operation dependent statement, the execution statement of each sub-operation and the comparison statement, wherein the execution sequence of the comparison statement is later than that of the execution statement of each sub-operation.
In a second aspect, the present application provides a test script generating apparatus, the apparatus comprising:
the first acquisition unit is used for responding to the triggering operation aiming at the recording key, monitoring the execution operation executed by the input equipment aiming at the target software and acquiring the test data corresponding to the execution operation; the execution operation comprises at least one sub-operation; the test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations, wherein each sub-operation in the execution operation aims at;
the second acquisition unit is used for acquiring script operation dependent statements; the script operation dependent statement is used for defining a preset function and parameter variables included by the preset function; the preset function comprises a positioning function and an operation function, the positioning function comprises a position variable, and the operation function comprises an action variable;
the analysis unit is used for analyzing the test data to obtain an operation parameter value of each sub-operation; the operating parameters comprise action parameters and position parameters;
the first assignment unit is configured to assign a parameter variable included in the preset function by using an operation parameter value of each sub-operation, so as to obtain an execution statement of each sub-operation;
and the generating unit is used for generating a test script according to the script operation dependent statement and the execution statement of each sub-operation, and the execution sequence of the execution statement of each sub-operation is determined according to the execution sequence among the sub-operations in the test data.
In a possible implementation manner, the test data is recorded in a first data table, each line of test data included in the first data table corresponds to one sub-operation, and the sequence of the lines of test data in the first data table corresponds to the execution sequence between the sub-operations;
the analysis unit is used for analyzing the test data included in the first data table line by line in sequence, determining action parameter values corresponding to the operation parameters of the sub-operations according to the operation objects and the operation action types which are aimed at by the sub-operations corresponding to each line of test data, and determining position parameter values corresponding to the operation parameters of the sub-operations according to the operation positions of the sub-operations corresponding to each line of test data to obtain a first operation parameter table; each row of data included in the first operation parameter table corresponds to one sub-operation, and each row of data includes an action parameter value and a position parameter value of the sub-operation; the row order of each row of data included in the first operation parameter list corresponds to an execution order among the respective sub-operations.
In a possible implementation manner, the first assigning unit is configured to assign an action variable of the operation function by using an action parameter value of a sub-operation included in first target data to obtain an action statement of the sub-operation corresponding to the first target data, where the action statement is formed by an operation function including the assigned action variable; the first target data is a row of data included in the first operation parameter table;
and assigning a value to the position variable of the positioning function by using the position parameter value of the sub-operation included in the first target data to obtain a position statement of the sub-operation corresponding to the first target data, wherein the position statement is composed of the positioning function including the assigned position variable.
In a possible implementation manner, the test data further includes an execution interval duration between two sub-operations adjacent to each other in the execution sequence; the preset function further comprises an interval duration function, and the interval duration function comprises a duration variable; the operating parameters further include an execution interval parameter; the test data are recorded in a second data table, each row of test data in the second data table corresponds to one sub-operation, and the sequence of the rows of test data in the second data table corresponds to the execution sequence among the sub-operations;
the analysis unit is configured to analyze the test data included in the second data table line by line in sequence, determine an action parameter value corresponding to an operation parameter of the sub-operation according to an operation object and an operation action type, which are targeted by the sub-operation corresponding to each line of test data, determine a position parameter value corresponding to the operation parameter of the sub-operation according to an operation position of the sub-operation corresponding to each line of test data, and obtain a second operation parameter table by taking an execution interval duration between two sub-operations adjacent to the execution sequence as an execution interval parameter value of the sub-operation;
each row of data included in the second operation parameter table corresponds to one sub-operation, and each row of data includes an action parameter value, a position parameter value and an execution interval parameter value of the sub-operation; the execution interval parameter value is used for indicating the execution interval duration between the sub-operation and the next sub-operation adjacent to the execution sequence; the row order of each row of data included in the second operation parameter table corresponds to an execution order between the respective sub-operations.
In a possible implementation manner, the first assignment unit is configured to assign an action variable of the operation function with an action parameter value of a sub-operation included in second target data to obtain an action statement of the sub-operation corresponding to the second target data, where the action statement is formed by the operation function including the assigned action variable; the second target data is a row of data included in the second operation parameter table;
assigning a position variable of the positioning function by using a position parameter value of the sub-operation included in the second target data to obtain a position statement of the sub-operation corresponding to the second target data, wherein the position statement is composed of the positioning function including the assigned position variable;
and assigning values to the duration variables included in the interval duration function by using the execution interval parameter values of the sub-operations included in the second target data to obtain execution interval statements of the sub-operations corresponding to the second target data, wherein the execution interval statements are composed of the interval duration function including the assigned duration variables.
In a possible implementation manner, the preset function further includes a screen capture function, and the screen capture function includes a storage location variable; the execution statement of each sub-operation further comprises a screen capture statement;
the device further comprises:
and the second assignment unit is used for assigning values to the storage position variables of the screen capture functions by using the target storage positions of the sub-operations to respectively obtain screen capture sentences of the sub-operations, the target storage positions are used for storing the screen capture images obtained by executing the sub-operations, and the screen capture sentences are formed by the screen capture functions comprising the assigned storage position variables.
In a possible implementation manner, the image name of the screenshot image of each sub-operation is determined according to the order in the execution sequence of the sub-operations, the image name of the standard image of each sub-operation is the same as the image name of the screenshot image of the sub-operation, and the standard image of each sub-operation is stored in the target storage location of the sub-operation; the preset function further includes a comparison function, the comparison function includes a path variable, the apparatus further includes:
the third assignment unit is used for assigning the target storage position of each sub-operation to the image path to obtain a comparison statement;
the generating unit is used for generating a test script according to the script operation dependent statement, the execution statement of each sub-operation and the comparison statement, wherein the execution sequence of the comparison statement is later than that of the execution statement of each sub-operation.
In a third aspect, the present application provides a test script generating device, including: a processor, a memory, a system bus; the processor and the memory are connected through the system bus;
the memory is configured to store one or more programs, where the one or more programs include instructions, which when executed by the processor, cause the processor to perform the test script generation method according to the first aspect and any one of the possible implementations of the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium, where the computer-readable storage medium stores instructions that, when executed on a terminal device, cause the terminal device to execute the test script generation method according to the first aspect and any one of the possible implementation manners of the first aspect.
Therefore, the application has the following beneficial effects:
the method comprises the steps of responding to a trigger operation aiming at a recording key, monitoring an execution operation executed by an input device aiming at target software, and acquiring test data corresponding to the execution operation, wherein the execution operation comprises at least one sub-operation, and the test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations aiming at each sub-operation in the execution operation; acquiring a script operation dependent statement, wherein the script operation dependent statement is used for defining a function required by executing the script and a variable of the function; analyzing the test data to obtain an operation parameter value of each sub-operation, wherein the operation parameter comprises an action parameter and an operation position parameter; assigning values to parameter variables included in a preset function by using the operation parameter value of each sub-operation to obtain an execution statement of each sub-operation; and generating a test script comprising the script dependency statements and the execution statements of each sub-operation according to the script operation dependency statements and the execution statements of each sub-operation. In this way, based on the acquired test data corresponding to the execution operation of the input device, the test data can be analyzed, and the execution statement for executing each sub-operation can be automatically generated based on the script operation dependent statement. And the test script can be generated according to the script running dependency statement and the execution statement of each sub-operation, so that the test script can be automatically generated, a tester does not need to manually write the test script, and the efficiency of generating the test script is improved.
Drawings
Fig. 1 is a schematic frame diagram of an exemplary application scenario of a test script generation method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a test script generation method according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a display interface of testing software according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a validation window of a test software according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a test script provided in an embodiment of the present application;
fig. 6 is a schematic diagram of a result display page provided in an embodiment of the present application;
fig. 7 is a schematic structural diagram of a test script generating apparatus according to an embodiment of the present application;
fig. 8 is a block diagram of an apparatus for generating a test script according to an embodiment of the present application.
Detailed Description
In order to facilitate understanding and explaining the technical solutions provided by the embodiments of the present application, the following description will first describe the background art of the present application.
In the process of managing software, a tester needs to test functions of the software and maintain problems found by the test. The tester manually writes a test script for testing according to the functions of the software. The tester can test the software function by running the test script. However, the time required for a tester to manually write a test script is long, writing errors are easy to occur, and the efficiency of generating the test script is low.
Based on this, the application provides a test script generation method, a device, equipment and a storage medium, the method monitors an execution operation executed by an input device for target software in response to a trigger operation for a recording key, and obtains test data corresponding to the execution operation, wherein the execution operation comprises at least one sub-operation, and the test data comprises an operation object, an operation action type, an operation position and an execution sequence between the sub-operations, which are targeted by each sub-operation in the execution operation; acquiring a script operation dependent statement, wherein the script operation dependent statement is used for defining functions required by executing the script and variables of the functions; analyzing the test data to obtain an operation parameter value of each sub-operation, wherein the operation parameter comprises an action parameter and a position parameter; assigning values to parameter variables included in a preset function respectively by using the operation parameter values of each sub-operation to obtain an execution statement of each sub-operation; and generating a test script comprising the script dependency statements and the execution statements of each sub-operation according to the script operation dependency statements and the execution statements of each sub-operation. In this way, based on the acquired test data corresponding to the execution operation of the input device, the test data can be analyzed, and the execution statement for executing each sub-operation can be automatically generated based on the script operation dependent statement. And the test script can be generated according to the script running dependency statement and the execution statement of each sub-operation, so that the test script can be automatically generated, a tester does not need to manually write the test script, and the efficiency of generating the test script is improved.
An application scenario of the test script generation method provided in the embodiment of the present application is described below with reference to fig. 1. Fig. 1 is a schematic diagram of a framework of an exemplary application scenario of a test script generation method according to an embodiment of the present application. The test script generation method provided by the embodiment of the application can be applied to test software.
In practical applications, a tester runs test software. The tester triggers a recording key displayed on an interface of the test software and starts to execute the execution operation aiming at the target software by using the input equipment. And the test software responds to the trigger operation aiming at the recording key to acquire the test data generated by the execution operation executed by the input equipment aiming at the target software. The test software acquires a script operation dependent statement, wherein the script operation dependent statement is a statement on which the script operates and is used for defining a preset function and a parameter variable included by the preset function. The script execution dependent statements may be preset in the device running the test software for test software acquisition. And analyzing the obtained test data by the test software to obtain the operation parameters of each sub-operation. The operation parameters are used for assigning values to parameter variables of the preset function. And respectively assigning values to parameter variables included in the preset function by using the operation parameters of each sub-operation to obtain an execution statement of each sub-operation. And finally, generating a test script according to the script running dependency statement and the execution statement of each sub-operation. The target software can read the test script, run the test script, restore and execute the operation, and realize the automatic test of the target software. In addition, the test script can be sent to other devices with the target software and the test software installed, and the test script is run in the other devices to realize the test of the target software.
Those skilled in the art will appreciate that the schematic diagram shown in fig. 1 is only one example in which embodiments of the present application may be implemented. The scope of applicability of the embodiments of the present application is not limited in any way by this framework.
In order to facilitate understanding of the technical solutions provided in the embodiments of the present application, the following describes a test script generation method provided in the embodiments of the present application with reference to the accompanying drawings.
First, it should be noted that the test script generation method provided in the embodiment of the present application can be applied to test software. The test software is used for testing the software. In some possible implementations, the test software can be applied to a computer. The embodiment of the application does not limit the operating environment suitable for the test software. As an example, the test software may be test software suitable for Linux (an operating system).
Referring to fig. 2, the figure is a flowchart illustrating a test script generation method provided in an embodiment of the present application, and as shown in fig. 2, the method may include S201 to S205.
S201: responding to a trigger operation aiming at a recording key, monitoring an execution operation executed by input equipment aiming at target software, and acquiring test data corresponding to the execution operation; the execution operation comprises at least one sub-operation; the test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations, wherein each sub-operation in the execution operation aims at.
The recording key is used for triggering monitoring of execution operation executed by the input device aiming at the target software. The embodiment of the application does not limit the specific implementation manner of the triggering operation for the recording key. In one possible implementation, the display interface of the test software includes a record button. As an example, the display interface of the test software may be as shown in FIG. 3. The display interface of the test software comprises a key for starting recording. The tester can realize the trigger operation aiming at the recording key by clicking the key for starting recording. In another possible implementation manner, the tester can implement the triggering operation for the recording key by triggering the shortcut key of the recording key.
And the test software responds to the trigger operation aiming at the recording key, starts monitoring the execution operation executed by the input equipment aiming at the target software, and acquires the test data of the execution operation.
The target software is the software that needs to be tested. The input device is a device connected to the computer for controlling the computer. The input device may include, but is not limited to, one or more of a mouse, a keyboard, and a touch input device. The execution operation can be determined by a tester according to the function to be tested of the target software.
In some possible implementations, the tester can obtain recorded data including the execution operation, such as a test case, by querying, and control the input device to execute the execution operation for the target software by referring to the recorded data. In other embodiments of the present application, the recorded data including the execution operation is not specifically limited. The test case may refer to a description of a test task performed on a specific software product, and the content of the test case may include a test object, a test environment, input data, a test procedure, an expected result, a test script, and the like. Each target software can correspond to a plurality of test cases, and each test case has a unique case number.
Referring to fig. 3, the display interface of the test software may further include an input box of a software name and an input box of a use case number. Before triggering the recording key, a tester can input the name of the target software in the input box of the software name and input the test case number of the test in the input box of the case number. The software name is used for identifying target software, and the case number is used for identifying a test case adopted by the test. The test software can query the test cases corresponding to the software name and the case number based on the software name and the case number. The test case is used for indicating specific contents of the execution operation, such as sub-operations included in the execution operation, an operation object, an operation action type and an operation position for each step of sub-operation, an execution sequence between the sub-operations, and the like. The corresponding relation between the software name and the case number and the test case can be pre-established and stored in the test case library. According to the test case, the tester can determine the specific content of the execution operation corresponding to the function of the target software to be tested conveniently, and the functional test of the target software is executed. Moreover, the test case is used as a reference standard of the execution operation, so that the determined execution operation is more accurate when the target software is tested for multiple times, and the test process of the target software is conveniently sorted by a tester.
It should be noted that the embodiment of the present application does not limit a specific implementation manner in which the input device performs the execution operation for the target software. In one possible implementation, the input device may be controlled to automatically perform the execution operation for the target software based on a pre-written script or instruction. In another possible implementation, the execution operation may be performed on the target software by a tester control input device.
The execution operation includes at least one sub-operation. A sub-operation is an operation that performs the smallest unit of the operation involved. Each sub-operation corresponds to an operation action. For example, the performing operation includes clicking a left mouse button at the A position, inputting content at the B position, and clicking a left mouse button at the C position. The execution operation includes three sub-operations: { sub-operation 1: click the left mouse button at position a }, { sub-operation 2: input content in B position }, { sub-operation 3: click the left mouse button at position C }. As can be seen, the execution operation may include an operation object, an operation action type, and an operation position for each sub-operation; when the number of sub-operations included in the execution operation is greater than 1, the execution operation also needs to include an execution order between the respective sub-operations. Further, when the number of sub-operations included in the execution operation is greater than 1, the execution operation may further include an execution interval duration between the respective sub-operations, for example, when { sub-operation 1: click left mouse button at position a, execute { sub-operation 2: input content at the B location }.
The test software monitors the execution operation executed by the input equipment aiming at the target software and acquires the test data corresponding to the execution operation. As an example, the test software starts a corresponding number of threads to realize the monitoring of the execution operation executed by each input device based on the number of the input devices. Input devices include, for example, a mouse and a keyboard. And the test software responds to the trigger operation aiming at the recording key, starts two threads, monitors the execution operation of the mouse and the execution operation of the keyboard respectively, and acquires test data generated according to the execution operation of the mouse and the execution operation of the keyboard respectively.
The embodiment of the application does not limit the specific implementation manner of obtaining the test data. In a possible implementation manner, the test data corresponding to the execution operation can be obtained in real time in the monitoring process. In another possible implementation, the test data may be obtained after determining that the execution operation is complete. As an example, the test software can determine that the execution of the operation ends based on the monitored end operation. The embodiment of the present application does not limit a specific implementation manner of the trigger end operation. For example, the test software can display an end key in a particular area of the screen. The tester can realize the trigger end operation by triggering the end key. For another example, the tester can trigger the end operation by triggering a shortcut key of a preset end key.
In the embodiment of the application, the test software may obtain test data corresponding to an execution operation executed by the input device for the target software based on monitoring of the input device, and the test data may be used to implement that the test software automatically executes the test operation for the target software. The test data comprises an operation object, an operation action type and an operation position of each sub-operation, wherein each sub-operation in the execution operation aims at; the test data also includes the order of execution between the various sub-operations. The operation action type refers to a type of operation action of the sub-operation. The operation action type is related to a device type of the input device. For example, if the input device includes a mouse, the operation action type may include a left mouse button triggering/clicking/double-clicking, a right mouse button triggering/clicking/double-clicking, a mouse wheel sliding up/down, and the like; the input device comprises a keyboard, and the operation action type can comprise keyboard input and the like; the input device comprises a touch input device, and the operation action type can comprise touch clicking, press triggering and the like.
As an example, the execution operation is { sub-operation 1: clicking a left mouse button at the position A; sub-operation 2: enter XX at position B. The execution operation comprises two sub-operations; the operation object of the sub-operation 1 is a mouse, the operation action type is clicking a left button of the mouse, and the operation position is the position A; the operation object of the sub-operation 2 is a keyboard, the operation action type is keyboard input XX, and the operation position is B position; the execution sequence of the sub-operations is as follows: sub-operation 1 is performed first, followed by sub-operation 2.
The operation position refers to a position at which a sub-operation is performed with respect to the operation object. In one possible implementation, the operating position may be represented using coordinates of a screen coordinate system. It should be noted that, taking a computer screen as an example, the upper left corner of the computer screen is the origin of coordinates, the horizontal rightward direction is the positive x-axis direction, and the vertical downward direction is the positive y-axis direction. One pixel length is a unit length. The value range of the coordinates is the maximum value of the resolution of the computer screen. Taking the sub-operation as { clicking the left mouse button at the a position } as an example, the operation position of the sub-operation is the coordinate of the a position in the screen coordinate system.
It should be noted that, in one possible implementation, the test software may display a confirmation window in response to the triggering operation for the record key. Referring to fig. 4, which is a schematic diagram of a confirmation window provided in the embodiment of the present application, the confirmation window may include a confirmation key and confirmation content. The confirmation content is used for prompting the tester to confirm that the recording is started to trigger the confirmation key. After confirming to start recording, the tester clicks a confirmation key in the confirmation window. And the test software responds to the trigger operation of the confirmation key, starts to monitor the execution operation executed by the input equipment aiming at the target software, and acquires the test data corresponding to the execution operation. In addition, the confirmation window may further include a cancel button. The confirmation content is also used for prompting the tester to select not to start recording by triggering a cancel key. By displaying the confirmation window, the tester can be prompted to start to acquire the test data corresponding to the execution operation, the tester can be prevented from mistakenly triggering the recording key to obtain invalid test data, and the acquired test data is accurate.
In some possible implementation manners, the test software responds to the trigger operation for the recording key, automatically creates a data file of a preset directory under a preset target path, and stores the acquired test data into the data file of the preset directory. The file name of the data file may be determined based on the acquired software name and use case number of the target software. The data file storing the test data may be a CSV (Comma-Separated Values) format file. For example, if a software name input by a tester in a display interface of test software is mspaint and a case number is mspa001, the test software automatically creates a folder [ mspaint ] corresponding to the software name in response to a trigger operation for a record key, and creates a test data directory [ mspa001] corresponding to the case number in a directory of the folder [ mspaint ] for storing the acquired test data. And meanwhile, log and replay _ data directories are created, wherein the log directories are used for storing logs of software operation, and the replay _ data directories are used for storing data corresponding to subsequent playback operations.
Furthermore, after the test data are acquired, the test software can display the test data in a display interface so that a tester can conveniently check the test data. The embodiment of the application does not limit the way of displaying the test data. As an example, an area for displaying test data is arranged in the display interface of the test software. As another example, after generating the test data, a popup window is generated for displaying the test data. The tester can check whether the test data is matched with the test operation required to be performed or not based on the displayed test data, and the test operation is ensured to meet the test requirement of the target software.
S202: acquiring a script operation dependent statement; the script operation dependent statement is used for defining a preset function and a parameter variable included by the preset function; the preset function comprises a positioning function and an operation function, the positioning function comprises a position variable, and the operation function comprises an action variable.
The script execution dependent statement is a statement on which the script is executed. The script run dependency statements can include one or more statements. The script operation dependent statement is used for defining a preset function related to the generation of the script and a parameter variable of the preset function. In the embodiment of the application, the test data corresponding to the execution operation includes operation information of two aspects of an operation action type and an operation position. The preset function includes a positioning function and an operation function. The positioning function comprises a position variable, and the positioning function is used for determining an operation position for executing the operation. The operation function includes an action variable, and the operation function is used to determine an operation action type for performing the operation.
In one possible implementation, the script execution dependent statements are stored in the form of dependent packages in the device that needs to execute the script. The tester can store the dependency package including the script operation dependency statement in a preset storage position in advance, so that the test software can read the script operation dependency statement included in the dependency package based on the preset storage position conveniently. It should be noted that the embodiment of the present application does not limit the trigger manner of obtaining the script running dependency statement. In a possible implementation manner, after test data corresponding to the execution operation is obtained, a test script is automatically triggered to be generated based on the test data; after the test data corresponding to the execution operation is obtained, the script operation dependent statement is automatically obtained, so that a test script is generated based on the script operation dependent statement and the test data in the following process. In another possible implementation, the test script is generated based on the test data triggered by the tester. Taking fig. 4 as an example, the display interface of the test software includes a "create script" button. The tester can trigger the operation of generating the test script based on the test data by clicking the 'script generation' key, and then the test software can spontaneously acquire the script operation dependence statement after the tester triggers the 'script generation' key.
S203: analyzing the test data to obtain an operation parameter value of each sub-operation; the operating parameters include an action parameter and a position parameter.
After the script operation dependent statement is obtained, the value of the parameter variable included in the preset function defined by the script operation dependent statement needs to be assigned. Specifically, the location function including the location variable and the operation function including the action variable need to be respectively assigned with values.
And analyzing the test data corresponding to the execution operation. And based on the operation parameter value of each sub-operation included in the test data, assigning values to the positioning function of the script running dependent statement and the variable included in the operation function.
In one possible implementation, for step S203: analyzing the test data to obtain an operation parameter value of each sub-operation.
S204: and assigning values to parameter variables included in the preset function by using the operation parameter values of each sub-operation to obtain an execution statement of each sub-operation.
And after the operation parameter value of each sub-operation is obtained, assigning values to the parameter variables included in the preset function by using the operation parameter value. Specifically, for each sub-operation included in the execution operation, an action parameter value included in an operation parameter value of the sub-operation is assigned to an action variable included in an operation function in a preset function, and a position parameter value included in the operation parameter value of the sub-operation is assigned to a position variable included in a positioning function in the preset function; and generating an execution statement corresponding to the sub-operation based on the obtained assigned preset function. And the execution statement of each sub-operation in the execution operation is run, the execution process aiming at each sub-operation can be restored, and the execution operation aiming at the target software is automatically executed.
It should be noted that, in the embodiment of the present application, the execution statement of the sub-operation may include a plurality of statements with different functions. In one possible implementation, the execution statements of the sub-operations include action statements and location statements. Wherein the action statement is used for executing the operation action of the sub-operation. The location statement is used to determine the location of the operation to perform the sub-operation. With respect to step S204: and assigning values to parameter variables included in the preset function by using the operation parameter values of each sub-operation to obtain an execution statement of each sub-operation.
S205: and generating a test script according to the script operation dependent statement and the execution statement of each sub-operation, wherein the execution sequence of the execution statement of each sub-operation is determined according to the execution sequence among the sub-operations in the test data.
The test script includes a script run dependency statement and an execution statement for each sub-operation. The execution statement for executing each sub-operation depends on the script execution dependency statement. The test script may include multiple lines of statements. Wherein the test script has a fixed number of lines written into the script running dependent statements. As an example, refer to fig. 5, which is a schematic diagram of a test script provided in an embodiment of the present application. Line 1 through line 12 of the test script the dependent statements are run by the test script.
The execution statements of the individual sub-operations comprised by the test script have an execution order. And the execution sequence of the execution statements of the sub-operations is determined according to the execution sequence among the sub-operations in the test data. In a possible implementation manner, the execution statements of each row are executed in sequence according to the row sequence number of each execution statement in the test script. And based on the execution sequence among the sub-operations included in the test data, sequentially writing the execution statements of the sub-operations into the test script line by line until the execution statement of the sub-operation with the last execution sequence is written into the test script, so as to obtain the complete test script.
After the test script is generated, a prompt window can also be displayed. And the prompt window is used for displaying a prompt message for completing the generation of the test script. For example, the hint message is "script generated". The tester can know the generation progress of the test script in time based on the displayed prompt window, and the tester can conveniently perform subsequent processing based on the test script. The generated test script can be stored in a preset storage location for the tester to retrieve or test the software call.
Taking the foregoing embodiment as an example, the software name input by the tester in the display interface of the test software is mspaint, and the case number is mspa001. In response to the trigger operation for the recording key, the test software automatically creates a folder [ mspaint ] corresponding to the software name, and creates a test data directory [ mspa001] corresponding to the case number under the directory of the folder [ mspaint ] for storing the acquired test data. Based on this, the test software automatically creates a [ mspa001] folder under the directory of the folder [ mspaint ], and the folder is used for storing the test script generated according to the test data. The name of the test script may be "mspa001.Py".
According to the test script generation method provided by the embodiment of the application, the test script used for restoring and executing the execution operation can be automatically generated based on the test data of the execution operation manually executed by the tester and the script operation dependent statement. Therefore, the test script does not need to be manually written by a tester, the efficiency of generating the test script is improved, and the labor cost is reduced. And the generated test script can be operated to realize the automatic test of the target software, the efficiency of testing the target software is improved, and the quick batch test of the regression test or the complicated and repeated test tasks is realized. In addition, the generated test script can also be applied to other systems or equipment with adaptive running environments, so that the target software can be tested conveniently.
In some possible implementations, the obtained test data corresponding to the execution operation may be stored in a data table. The test software is able to determine the test operation to be performed by parsing the data table.
Step S203 provided in the embodiment of the present application is as follows: and analyzing the test data to obtain two specific implementation modes of the operation parameter value of each sub-operation for introduction.
A first possible implementation: the test data is recorded in a first data table. The test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations, wherein each sub-operation in the execution operation aims at. The first data table includes one sub-operation for each row of test data. The ordering of the rows of test data in the first data table corresponds to the order of execution between the sub-operations.
The first data table comprises a plurality of rows of test data, and each row of test data corresponds to one sub-operation; the ordering of the rows of test data in the data table corresponds to the order of execution between the various sub-operations.
As an example, it is assumed that the execution operation performed by the tester control input device includes four sub-operations, which are: { sub-operation 1: clicking a right mouse button to open a desktop menu of the target software; sub-operation 2: clicking a left mouse button to select and open software from a menu; sub-operation 3: clicking a left mouse button to open a 'file' option bar in a menu bar of the target software; sub-operation 4: clicking the left mouse button triggers the "Exit" button in the "File" tab }. The test data corresponding to the execution operation comprises 4 rows of test data, and each row of test data corresponds to each sub-operation of the execution operation; specifically, each line of test data comprises an operation object, an operation action type and an operation position of each sub-operation, wherein each sub-operation is aimed at; and the sequence of each row of test data corresponds to the execution sequence among the sub-operations. The test data is shown in table 1:
serial number Type of operation action Operating position
1 button.right (65,850)
2 button.left (153,372)
3 button.left (478,244)
4 button.left (508,510)
TABLE 1
The sequence numbers are used for identifying the sequence of the test data of different rows, and respectively correspond to the execution sequence of the 4 sub-operations in the execution operation.
The test data of the row with sequence number 1 corresponds to { sub-operation 1: clicking the right mouse button to open the desktop menu of the target software }. The operation object for the sub-operation 1 is "button", the operation action type is "button. Right represents clicking the right mouse button; (65, 850) the position coordinates in the screen coordinate system of the operation of clicking the right button of the mouse.
The test data of the row with sequence number 2 corresponds to { sub-operation 2: clicking the left mouse button selects the software to be opened from the menu }. The operation object targeted by the sub-operation 2 is "button", the operation action type is "button. Left represents clicking the left mouse button; (153, 372) position coordinates in the screen coordinate system of the operation of clicking the left button of the mouse are represented.
The test data of the row with sequence number 3 corresponds to { sub-operation 3: clicking the left mouse button opens the "file" option bar "in the menu bar of the target software. The operation object for the sub-operation 3 is "button", the operation action type is "button. Left represents clicking the left mouse button; (478, 244) represents position coordinates in the screen coordinate system of the operation of clicking the left button of the mouse.
The test data of the row with sequence number 4 corresponds to { sub-operation 4: clicking the left mouse button triggers the "Exit" button in the "File" option bar }. The sub-operation 4 targets the operation object as "button", the operation action type as "button. Left represents clicking the left mouse button; (508, 510) represents the position coordinates in the screen coordinate system of the operation of clicking the left button of the mouse.
For the test data corresponding to the first implementation manner, the embodiment of the present application provides a specific implementation manner for analyzing the test data to obtain the operation parameter value of each sub-operation.
Analyzing the test data included in the first data table line by line in sequence, determining action parameter values corresponding to the operation parameters of the sub-operations according to the operation objects and the operation action types which are aimed at by the sub-operations corresponding to each line of test data, determining position parameter values corresponding to the operation parameters of the sub-operations according to the operation positions of the sub-operations corresponding to each line of test data, and obtaining a first operation parameter table.
The first data table comprises a plurality of rows of data, and each row of test data corresponds to one sub-operation in the execution operation. And the test software analyzes the test data included in the first data table line by line in sequence. By analyzing line by line sequentially, the operation object, the operation action type and the operation position of each sub-operation corresponding to each sub-operation included in the execution operation can be obtained sequentially.
And analyzing the operation object and the operation action type corresponding to the obtained sub-operation, and determining the action parameter value of the sub-operation. In some possible implementation manners, a corresponding relationship between the operation object and the operation action type and the value of the action parameter is established in advance.
Based on the established corresponding relationship between the operation object and the operation action type and the value of the action parameter, the action parameter value of the operation parameter of the sub-operation corresponding to the row of test data can be determined according to the operation object and the operation action type included in the row of test data in the first data table. For example, a corresponding relationship between { the operation object is a right mouse button and the operation action type is a click }, and { the value of the action parameter is 0} may be preset; in this way, when the operation object corresponding to the sub-operation obtained through analysis is a right mouse button and the operation action type is clicking, the value of the action parameter is determined to be 0. For another example, a corresponding relationship between { the operation object is a left mouse button and the operation action type is a click }, and { the value of the action parameter is 1} is preset; in this way, when the operation object corresponding to the sub-operation obtained through analysis is the left mouse button and the operation action type is clicking, the value of the action parameter is determined to be 1. In another possible implementation manner, the data type of the operation object and the data type of the operation action type are the same as the data type of the action parameter, and the operation object and the operation action type can be directly used as action parameter values of the operation parameter.
And determining the position parameters of the sub-operation according to the operation position of the sub-operation obtained by analysis. In some possible implementations, the operation position is a coordinate, and a coordinate value of the operation position is taken as a value of the position parameter. In another possible implementation, the operation position is data indicating coordinates included in a screen coordinate system. Firstly, determining coordinates in a screen coordinate system corresponding to the operation position according to the operation position, and then taking coordinate values of the obtained coordinates as values of position parameters in the operation parameters. For example, the operation position is a vector of relative positions based on a preset standard position. And determining the coordinate value of the screen coordinate system corresponding to the operation position based on the coordinates of the operation position and the standard position in the screen coordinate system. And taking the coordinate value of the screen coordinate system corresponding to the obtained operation position as the value of the position parameter.
Take the first data table shown in table 1 as an example. If the operation object 'button' and the operation action type of the test data of the row with the sequence number 1 are 'button.right', the value of the action parameter is 0; if the operation position is "(65, 850)", the value of the position parameter is (65, 850). If the operation object ' button ' and the operation action type of the test data of the row with the sequence number 2 are ' button. The operation position is (153, 372), and the value of the position parameter is (153, 372). If the operation object ' button ' and the operation action type of the test data of the row with the sequence number 3 are ' button. If the operation position is "(478, 244)", the value of the position parameter is (478, 244). If the operation object ' button ' and the operation action type of the test data of the row with the sequence number 4 are ' button. If the operation position is "(508, 510)", the value of the position parameter is (508, 510).
The first operating parameter table may include a multi-row list. Each row list corresponds to a sub-operation. Each row list comprises action parameter values and position parameter values corresponding to one sub-operation. The first operation parameter table includes an order of each row list corresponding to an execution order of the sub-operations corresponding to each row list. The resulting first operating parameter table is shown in table 2:
[0,(65,850)]
[1,(153,372)]
[1,(478,244)]
[1,(508,510)]
TABLE 2
After the first operation parameter table is obtained, an execution statement of the sub-operation corresponding to each line list can be generated based on the action parameter value and the position parameter value in each line list included in the first operation parameter table.
Based on the first operation parameter table, the embodiment of the present application provides step S204: and assigning values to parameter variables included in the preset function by using the operation parameter values of each sub-operation to obtain a specific implementation mode of the execution statement of each sub-operation.
And taking one row of data in the first operating parameter table as first target data. And generating an execution statement of the sub-operation corresponding to the first target data based on the action parameter value and the position parameter value included in the first target data.
It should be noted that the embodiment of the present application does not limit the method for determining the first target data. In a possible implementation manner, the data in each row are sequentially used as the first target data according to the sequence of the data in each row included in the first operation parameter table, so as to obtain an execution statement of the sub-operation corresponding to the data in each row.
The execution statement of the sub-operation corresponding to the first target data includes an action statement and a position statement. And the action statement is used for executing the operation according to the operation action type of the sub-operation corresponding to the first target data. The position statement is used for determining an operation position for executing the sub-operation corresponding to the first target data.
And assigning values to action variables of the operation functions included in the preset function according to the action parameter values included in the first target data. And based on the operation function assigned by the action variable, an action statement of the operation action type for executing the sub-operation corresponding to the first target data can be generated.
As an example, taking the first row data [0, (65, 850) ] in table 2 above as the first target data, the operation functions are mouse. The action parameter value 0 is used to assign the action variable included in the operation function, and the obtained operation function including the assigned action variable is mouse. Action statements generated based on the operation function including the assigned action variable are respectively mouse. Press (button. Right), among others, is used to realize pressing of the right mouse button. Release (button right) is used to effect release after pressing the right mouse button. As such, clicking the right mouse button can be implemented based on mouse.
And acquiring a position parameter value from the first target data, and assigning a value to the position variable of the positioning function by using the position parameter value. And generating a position statement based on the positioning function after the position variable is assigned.
As an example, taking the first row data in table 2 above as the first target data, the positioning function is use. The position variables included in the positioning function are assigned with the position parameter values (65, 850), and the obtained positioning function including the assigned position variables is mouse position = (65, 850). The position statement generated based on the positioning function including the assigned position variable is use. Position = (65, 850) is used to determine an operation position at which the mouse is operated.
It should be noted that the execution order of the position statements of the sub-operations corresponding to the first target data in the test script is earlier than the execution order of the action statements of the sub-operations corresponding to the first target data. Based on the obtained position statement and action statement of the sub-operation corresponding to the first target data, the operation action type determined by the action statement can be executed at the execution operation position determined based on the position statement, and the sub-operation corresponding to the first target list can be restored.
A second possible implementation: the test data is recorded in a second data table. The test data comprises an operation object, an operation action type, an operation position, an execution interval duration between two adjacent sub-operations in the execution sequence and the execution sequence between the sub-operations, wherein each sub-operation in the execution operation aims at. The second data table includes one sub-operation for each row of test data. The ordering of the rows of test data in the second data table corresponds to the order of execution between the sub-operations.
The execution interval duration is the execution interval duration between two sub-operations adjacent to each other in the execution sequence; for example, the execution interval duration may be a duration between an execution end time of a sub operation whose execution order is prior and an execution start time of a sub operation whose execution order is later, among two sub operations whose execution orders are adjacent.
Correspondingly, the preset function further comprises an interval duration function, and the interval duration function comprises a duration variable; the operating parameters also include an execution interval parameter.
As an example, it is assumed that the execution operation performed by the tester control input device includes four sub-operations, which are: { sub-operation 1: clicking a right mouse button to open a desktop menu of the target software; sub-operation 2: clicking a left mouse button to select and open software from a menu; sub-operation 3: clicking a left mouse button to open a 'file' option bar in a menu bar of the target software; sub-operation 4: clicking the left mouse button triggers the "Exit" button in the "File" option bar }. The test data corresponding to the execution operation comprises 4 rows of test data, and each row of test data corresponds to each sub-operation of the execution operation; specifically, each line of test data comprises an operation object aimed at by each sub-operation, an operation action type, an operation position of each sub-operation, and an execution interval duration between adjacent sub-operations; and the sequence of each row of test data corresponds to the execution sequence among the sub-operations. The test data is shown in table 3:
serial number Type of operation action Operating position Duration of execution interval
1 button.right (65,850) 2.51
2 button.left (153,372) 2.09
3 button.left (478,244) 3.77
4 button.left (508,510) 3.5
TABLE 3
The sequence numbers are used for identifying the sequence of the test data of different rows, and respectively correspond to the execution sequence of the 4 sub-operations in the execution operation.
The test data of the row with sequence number 1 corresponds to { sub-operation 1: clicking the right mouse button to open the desktop menu of the target software }. The operation object targeted by the sub-operation 1 is "button", the operation action type is "button, the operation position is (65, 850), and the execution interval duration between the sub-operation 1 and the next adjacent sub-operation (sub-operation 2) is 2.51 seconds. Right represents clicking a right mouse button, and (65, 850) represents position coordinates of the right mouse button in a screen coordinate system; 2.51 indicates that sub-operation 2 is started after an interval of 2.51 seconds after the end of sub-operation 1.
The test data of the row with sequence number 2 corresponds to { sub-operation 2: clicking the left mouse button selects the software to be opened from the menu }. The operation object targeted by the sub-operation 2 is "button", the operation action type is "button. Left represents clicking the left mouse button; (153, 372) position coordinates in a screen coordinate system of an operation of clicking a left button of the mouse are represented; 2.09 indicates that sub-operation 3 is started after 2.09 seconds after the sub-operation 2 is completed.
The test data of the row with sequence number 3 corresponds to { sub-operation 3: clicking the left mouse button opens the "file" option bar "in the menu bar of the target software. The operation object targeted by the sub-operation 3 is "button", the operation action type is "button. Left", the operation positions are (478, 244), and the execution interval duration between the sub-operation 3 and the next adjacent sub-operation (sub-operation 4) is 3.77 seconds. Left represents clicking the left mouse button; (478, 244) indicating position coordinates in the screen coordinate system of an operation of performing a click of a left button of the mouse; 3.77 indicates that sub-operation 4 starts to be executed after an interval of 3.77 seconds after the execution of sub-operation 3 ends.
The test data of the row with sequence number 4 corresponds to { sub-operation 4: clicking the left mouse button triggers the "Exit" button in the "File" option bar }. The operation object targeted by the sub-operation 4 is "button", the operation action type is "button. Left", the operation positions are (508, 510), and the execution interval duration between the sub-operation 4 and the next adjacent sub-operation is 3.5 seconds. Left represents clicking the left mouse button; (508, 510) position coordinates in a screen coordinate system of an operation of clicking a left button of the mouse are expressed; 3.5 indicates that after the execution of sub-operation 4 is finished, the next sub-operation starts to be executed (end operation) after an interval of 3.5 seconds.
The next sub-operation of sub-operation 4 is an end operation, and the corresponding test data is null.
For the test data corresponding to the second implementation manner, the embodiment of the present application provides a specific implementation manner for analyzing the test data to obtain the operation parameter value of each sub-operation.
Analyzing the test data included in the second data table line by line according to the execution interval duration, determining action parameter values corresponding to the operation parameters of the sub-operations according to the operation objects and the operation action types which are aimed at by the sub-operations corresponding to each line of test data, determining position parameter values corresponding to the operation parameters of the sub-operations according to the operation positions of the sub-operations corresponding to each line of test data, and taking the execution interval duration between two sub-operations adjacent to the execution sequence as the execution interval parameter values to obtain a second operation parameter table.
The second data table comprises a plurality of rows of data, and each row of test data corresponds to one sub-operation in the execution operation. And the test software analyzes the test data included in the second data table line by line in sequence. By analyzing line by line in sequence, the operation object, the operation action type, the operation position of each sub-operation and the execution interval duration between two adjacent sub-operations which are respectively corresponding to each sub-operation included in the execution operation can be obtained in sequence.
Based on the operation object and the operation action type corresponding to the sub-operation obtained by analysis, the action parameter value of the sub-operation can be determined. In some possible implementations, the data type of the operation object and the data type of the operation action type are different from the data type of the action parameter. And establishing a corresponding relation between the operation object and the operation action type and the value of the action parameter in advance. Based on the established corresponding relationship between the operation object and the operation action type and the value of the action parameter, the action parameter value of the sub-operation corresponding to the row of test data can be determined according to the operation object and the operation action type included in the row of test data in the second data table. In another possible implementation manner, the data type of the operation object and the data type of the operation action type are the same as the data type of the action parameter, and the operation object and the operation action type can be directly used as values of the action parameter.
And determining the position parameter value of the operation parameter of the sub-operation according to the operation position of the sub-operation obtained by analysis. In some possible implementation manners, the operation position is a coordinate of a screen coordinate system, and a coordinate value of the operation position is used as a value of the position parameter. In another possible implementation, the operation position is data indicating coordinates included in a screen coordinate system. Firstly, the coordinates included in the screen coordinate system are determined according to the operation position, and then the coordinate values of the obtained coordinates are used as the values of the position parameters. For example, the operation position is a vector of relative positions based on a preset standard position. And determining the coordinate value of the screen coordinate system corresponding to the operation position based on the operation position and the coordinates of the standard position in the screen coordinate system. And taking the coordinate value of the screen coordinate system corresponding to the obtained operation position as the value of the position parameter.
And analyzing the test data included in the second data table to obtain the execution interval duration between two sub-operations adjacent to each other in the execution sequence. And taking the execution interval duration between two sub-operations adjacent in the execution sequence as an execution interval parameter value corresponding to the sub-operation before the execution sequence between the two sub-operations adjacent in the execution sequence.
Take the second data table shown in table 3 as an example. The operation object button and the operation action type of the test data of the row with the sequence number 1 are button, and the value of the action parameter is 0; the operation position is "(65, 850)", and the value of the position parameter is (65, 850); the execution interval duration is "2.51", and the value of the execution interval parameter is 2.51. The operation object button and the operation action type of the test data of the row with the sequence number 2 are button, left, and the value of the action parameter is 1; the operation position is (153, 372), and the value of the position parameter is (153, 372); the execution interval duration is "2.09", and the value of the execution interval parameter is 2.09. The operation object button and the operation action type of the test data of the row with the sequence number 3 are button, left, and the value of the action parameter is 1; the operation position is (478, 244), and the value of the position parameter is (478, 244); the execution interval duration is "3.77", and the value of the execution interval parameter is 3.77. The operation object button and the operation action type of the test data of the row with the sequence number 4 are button, left, and the value of the action parameter is 1; the operation position is (508, 510), "and the value of the position parameter is (508, 510); the execution interval duration is "3.5", and the value of the execution interval parameter is 3.5.
The second operating parameter table may include a multi-row list. Each row list corresponds to a sub-operation. Each row list comprises action parameter values and position parameter values corresponding to one sub-operation. The order of each row list included in the second operation parameter table is consistent with the execution order of the sub-operations corresponding to each row list, and the obtained second operation parameter table is shown in table 4:
[0,(65,850),2.51]
[1,(153,372),2.09]
[1,(478,244),3.77]
[1,(508,510),3.5]
TABLE 4
After the second operation parameter table is obtained, the execution statements of the sub-operations corresponding to each row list can be generated based on the action parameter values, the position parameter values and the execution interval durations in each row list included in the second operation parameter table.
Based on the second operation parameter table, the embodiment of the present application provides step S204: and assigning values to parameter variables included in the preset function by using the operation parameter values of each sub-operation to obtain a specific implementation mode of the execution statement of each sub-operation.
And taking one row of data in the second operation parameter table as second target data. And generating an execution statement of the sub-operation corresponding to the second target data based on the action parameter value, the position parameter value and the execution interval parameter value included in the second target data.
It should be noted that the embodiment of the present application does not limit the method for determining the second target data. In a possible implementation manner, the data in each row are sequentially used as second target data according to the order of the data in each row included in the second operation parameter table, so as to obtain an execution statement of the sub-operation corresponding to the data in each row.
The execution statements of the sub-operations corresponding to the second target data include action statements, position statements, and execution interval statements. And the action statement is used for executing the operation according to the operation action type of the sub-operation corresponding to the second target data. The position statement is used for determining an operation position for executing the sub-operation corresponding to the second target data. The execution interval statement is used for controlling the interval duration between the ending execution time of the execution statement of the sub-operation corresponding to the second target data and the starting execution time of the execution statement of the next sub-operation of the sub-operation corresponding to the second target data.
And assigning the action variable of the operation function included in the preset function according to the action parameter value included in the second target data. And based on the operation function after the action variable is assigned, an action statement of the operation action type for executing the sub-operation corresponding to the second target data can be generated.
The manner of generating the action statement based on the action parameter value is similar to that of generating the action statement based on the action parameter value in the first possible implementation manner, and please refer to the above description, which is not repeated herein.
And acquiring a position parameter value from the second target data, and assigning a value to the position variable of the positioning function by using the position parameter value. And generating a position statement based on the positioning function after the position variable is assigned.
The manner of generating the location statement based on the location parameter value is similar to that of generating the location statement based on the location parameter value in the first possible implementation manner, and for details, refer to the above description, and are not described herein again.
The interval duration function and the duration variable included by the interval duration function are both defined by the script operation dependent statement. And after the execution interval duration included by the second target data is obtained, assigning a value to the duration variable included by the interval duration function by using the execution interval duration. And generating an execution interval statement based on the interval duration function after the duration variable is assigned.
As an example, taking the first row data [0, (65, 850), 2.51] in table 4 above as the second target data, the interval duration function is sleep () which includes the variable to be written in the duration variable (). And assigning a duration variable included in the interval duration function by using the execution interval duration 2.51, wherein the obtained interval duration function including the assigned duration variable is sleep (2.51). The execution interval statement generated based on the interval duration function including the assigned duration variable is sleep (2.51). The execution interval statement sleep (2.51) is used to control the time interval between the end execution time of the sub-operation corresponding to the first row of data and the start execution time of the sub-operation corresponding to the second row of data in table 4.
It should be noted that the execution order of the position statement of the sub-operation corresponding to the second target data is earlier than the execution order of the action statement of the sub-operation corresponding to the second target data, and the execution order of the action statement of the sub-operation corresponding to the second target data is earlier than the execution order of the execution interval statement of the sub-operation corresponding to the second target data. Based on the obtained position statement, action statement and execution interval statement of the sub-operation corresponding to the second target data, the operation action type determined by the action statement can be executed at the execution operation position determined based on the position statement, and the sub-operation corresponding to the second target data can be restored. And after the action statement is executed, the execution interval statement can be executed, so that a certain time interval is formed between the sub-operation corresponding to the second target data and the next sub-operation of which the execution sequence is the sub-operation corresponding to the second target data, the target software can respond to the executed sub-operation conveniently, and a more accurate execution result can be obtained.
In a possible implementation manner, in the process of running the test script, a screenshot needs to be performed on the display interface of the target software, and the obtained screenshot image is used for comparing with a standard image of the display interface of the target software to obtain a test result for the target software. The test script generated by the test software also comprises a screen capture statement used for capturing a screen of the display interface of the target software. Based on this, the embodiment of the present application provides a test script generating method. The preset functions defined by the script operation dependent statements further comprise screen capture functions. The screen capture function includes a storage location variable. And the screen capture function is used for executing screen capture operation and storing the generated screen capture image in the storage space indicated by the assigned storage position variable. As an example, the screen capture function is screen _ shot = screen shot ().
In addition to the above steps, in the above S205: before generating a test script according to the script running dependency statement and the execution statement of each sub-operation, the method further comprises the following steps:
and assigning values to the storage position variables of the screen capture functions by using the target storage positions of each sub-operation to respectively obtain the screen capture sentences of each sub-operation, wherein the screen capture sentences are formed by the screen capture functions comprising the assigned storage position variables, and the target storage positions are used for storing the screen capture images obtained by executing the sub-operations.
And the target storage position of the sub-operation is a predetermined storage position for storing the screenshot image obtained after the sub-operation is simulated and executed in the process of running the test script. And taking the target storage position of the sub-operation as the storage position parameter of the sub-operation. Taking the above-mentioned example that in response to the trigger operation for the recording key, the test software automatically creates the folder [ mspaint ] corresponding to the software name, in the process of generating the test script corresponding to the test data of the case number mspa001, the generated screenshot image is stored in the [ mspa001] folder created under the directory of the folder [ mspaint ]. The [ mspa001] folder created under the directory of the folder [ mspaint ] serves as a folder for storing the screenshot image. The target memory location is denoted mspaint/mspa001. It should be noted that, in the case where the execution operation includes a plurality of sub-operations, the target storage locations of the respective sub-operations may be different. The target storage location of each sub-operation can be set in advance.
And assigning values for storage position variables of the screen capture functions by using the target storage positions of the sub-operations to respectively obtain screen capture sentences of the sub-operations. And the screen capture statement is a screen capture function after the storage position variable is assigned.
In some possible implementations, the screen capture function also includes a name variable. The name variable is used to determine the name of the screenshot image. The name variable is determined according to the execution order of the sub-operations. Taking the screen capture function as screen _ shot = screen shot (), and the target storage location is mspage/mspa 001 as an example, the screen capture statement of the sub-operation whose execution sequence is the first is screen _ shot. And executing the screenshot sentence to capture a display interface of the target software to obtain a screenshot image which is stored in the mspaint/mspa001 and is named 1. Png.
The test script can also compare the standard image corresponding to each sub-operation with the generated screenshot image of the sub-operation to obtain a test result. And the standard image corresponding to each sub-operation is obtained by screenshot of a display interface displayed by the target software in response to each sub-operation executed in the execution operation. The standard image is used as a standard for judging the normal operation of the target software and is used for comparing with a screenshot image obtained in the subsequent test script execution process, so that the test result is automatically determined. In one possible implementation, the image name of the screenshot image of each sub-operation is determined according to the order of the execution order of the sub-operations. The image name of the standard image of each sub-operation is the same as that of the screenshot image of the sub-operation. And, the standard image of each sub-operation is stored in the target storage location of the sub-operation. In the test script generation method provided by the embodiment of the application, the preset function defined by the script running dependency statement further includes a comparison function. The contrast function includes a path variable. And the comparison function is used for reading the image stored under the path based on the path indicated by the assigned path variable and comparing the image.
In addition to the above steps, in the above S205: before generating a test script according to the script running dependency statement and the execution statement of each sub-operation, the method further comprises the following steps:
and assigning the target storage position of each sub-operation to the path variable to obtain a comparison statement corresponding to each sub-operation.
In one possible implementation, each sub-operation has a corresponding, separately run, compare statement. In another possible implementation manner, the target storage locations of the sub-operations are the same, and the target storage locations can be accessed by running a comparison statement once, and the screenshot images of the sub-operations and the standard images of the sub-operations are read, so that comparison between the screenshot images of the sub-operations and the standard images corresponding to the sub-operations is realized.
As an example, the comparison sentence includes a sentence of acquiring a standard image of a sub operation that needs to be compared and a screenshot image of the sub operation, and a sentence of comparison of the standard image of the sub operation and the screenshot image of the sub operation. As an example, the contrast statement includes similar = similar (str (case _ path), click _ cnt) and similar. Wherein str (case _ path) is an assigned path variable, and a value of str (case _ path) is a target storage location. The click _ cnt is the number of sub-operations included in the execution operation, that is, the number of screenshot images that need to be compared. Based on the value of the click _ cnt, the value range of the order of the execution order of the sub-operations can be determined. By running a similar = similar (str _ path) statement, the target storage location can be accessed, and the screenshot image and the standard image which need to be compared and are determined according to the order of the execution sequence of each sub-operation and have the same image name are acquired. By operating similar.
Further, S205: the generating a test script according to the script running dependency statement and the execution statement of each sub-operation comprises:
and generating a test script according to the script operation dependent statement, the execution statement of each sub-operation and the comparison statement.
Wherein the execution order of the comparison statements is later than the execution order of the execution statements of each sub-operation. Therefore, the comparison between the screenshot image and the standard image can be carried out after the execution sentence is operated to obtain the screenshot image, the comparison result between the screenshot image and the standard image is obtained, and the test result for the target software is obtained.
It should be noted that, in one possible implementation manner, the test software can load the generated test script, and implement subsequent testing on the target software by using the test script. The test software is capable of obtaining the test script in response to the get script load operation. The embodiment of the present application does not limit a specific implementation manner of triggering a script loading operation. In one possible implementation manner, triggering of the script loading operation is realized by triggering a key in a display interface of the test software by a tester. As an example, the display interface of the test software includes a "import script" button. The tester can trigger the script loading operation by clicking the key of the 'import script'. In another possible implementation, the test software is pre-configured to detect the file of the test script in a specific storage space. And after detecting that the test script exists, the test software automatically triggers script loading operation. The test software can also display a script loading page, and the script loading page is used for displaying the script name of the test script and the execution condition data of the test script. The execution condition data of the test script indicates the execution condition of the test script. As an example, the execution data of the test script includes an execution status. The execution state includes an unexecuted state and an executed state. In some possible implementations, the execution condition data of the test script further includes the execution times of the test script, the completion time of the test script, and the execution result of the test script. When the execution state is the executed state, the corresponding execution times of the test script, the execution time of the test script and the execution result of the test script are all null values.
Referring to fig. 6, this figure is a schematic diagram of a result display page provided in the embodiment of the present application. The script loading page comprises a script name of the test script and execution condition data of the test script. The execution condition data of the test script comprises the execution state of the test script, the completion time of the test script and the execution result of the test script. The script name of the test script is "mspaint001". Wherein, the 'mspaint' is the name of the target software, and 001 is the case number. The execution state is an unexecuted state, and the execution result and the completion time are both null values.
Based on the test script generation method provided by the embodiment of the present application, an embodiment of the present application provides a test script generation device, which is shown in fig. 7, and is a schematic structural diagram of the test script generation device provided by the embodiment of the present application. The test script generating device includes:
a first obtaining unit 701, configured to monitor, in response to a trigger operation for a recording key, an execution operation executed by an input device for target software, and obtain test data corresponding to the execution operation; the execution operation comprises at least one sub-operation; the test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations, wherein each sub-operation in the execution operation aims at;
a second obtaining unit 702, configured to obtain a script operation dependent statement; the script operation dependent statement is used for defining a preset function and parameter variables included by the preset function; the preset function comprises a positioning function and an operation function, the positioning function comprises a position variable, and the operation function comprises an action variable;
an analyzing unit 703, configured to analyze the test data to obtain an operation parameter value of each sub-operation; the operation parameters comprise action parameters and position parameters;
a first assignment unit 704, configured to assign a parameter variable included in the preset function by using an operation parameter value of each sub-operation, respectively, to obtain an execution statement of each sub-operation;
a generating unit 705, configured to generate a test script according to the script running dependency statement and the execution statement of each sub-operation, where an execution order of the execution statement of each sub-operation is determined according to an execution order between the sub-operations in the test data.
In a possible implementation manner, the test data is recorded in a first data table, each line of test data included in the first data table corresponds to one sub-operation, and the sequence of the lines of test data in the first data table corresponds to the execution sequence between the sub-operations;
the analyzing unit 703 is configured to sequentially analyze the test data included in the first data table line by line, determine an action parameter value corresponding to an operation parameter of the sub-operation according to an operation object and an operation action type of the sub-operation corresponding to each line of test data, and determine a position parameter value corresponding to the operation parameter of the sub-operation according to an operation position of the sub-operation corresponding to each line of test data, to obtain a first operation parameter table; each line of data included in the first operation parameter table corresponds to one sub-operation, and each line of data includes an action parameter value and a position parameter value of the sub-operation; the row order of each row of data included in the first operation parameter list corresponds to an execution order among the respective sub-operations.
In a possible implementation manner, the first assigning unit 704 is configured to assign an action variable of the operation function by using an action parameter value of a sub-operation included in first target data, to obtain an action statement of the sub-operation corresponding to the first target data, where the action statement is formed by the operation function including the assigned action variable; the first target data is a row of data included in the first operation parameter table;
and assigning a value to the position variable of the positioning function by using the position parameter value of the sub-operation included in the first target data to obtain a position statement of the sub-operation corresponding to the first target data, wherein the position statement is composed of the positioning function including the assigned position variable.
In a possible implementation manner, the test data further includes an execution interval duration between two sub-operations adjacent to each other in the execution sequence; the preset function further comprises an interval duration function, and the interval duration function comprises a duration variable; the operating parameters further include an execution interval parameter; the test data are recorded in a second data table, each row of test data in the second data table corresponds to one sub-operation, and the sequence of the rows of test data in the second data table corresponds to the execution sequence among the sub-operations;
the analyzing unit 703 is configured to sequentially analyze the test data included in the second data table line by line, determine an action parameter value corresponding to an operation parameter of the sub-operation according to an operation object and an operation action type, which are targeted by the sub-operation, corresponding to each line of test data, determine a position parameter value corresponding to the operation parameter of the sub-operation according to an operation position of the sub-operation, which corresponds to each line of test data, and use an execution interval duration between two sub-operations adjacent to each other in the execution sequence as an execution interval parameter value of the sub-operation, so as to obtain a second operation parameter table;
each row of data included in the second operation parameter table corresponds to one sub-operation, and each row of data includes an action parameter value, a position parameter value and an execution interval parameter value of the sub-operation; the execution interval parameter value is used for indicating the execution interval duration between the sub-operation and the next sub-operation adjacent to the execution sequence; the row order of each row of data included in the second operation parameter table corresponds to an execution order between the respective sub-operations.
In a possible implementation manner, the first assigning unit 704 is configured to assign an action variable of the operation function by using an action parameter value of a sub-operation included in second target data, to obtain an action statement of the sub-operation corresponding to the second target data, where the action statement is formed by the operation function including the assigned action variable; the second target data is a row of data included in the second operation parameter table;
assigning values to the position variables of the positioning functions by using the position parameter values of the sub-operations included in the second target data to obtain position statements of the sub-operations corresponding to the second target data, wherein the position statements are formed by the positioning functions including the assigned position variables;
and assigning values to the duration variables included in the interval duration function by using the execution interval parameter values of the sub-operations included in the second target data to obtain execution interval statements of the sub-operations corresponding to the second target data, wherein the execution interval statements are composed of the interval duration function including the assigned duration variables.
In a possible implementation manner, the preset function further includes a screen capture function, and the screen capture function includes a storage location variable; the execution statement of each sub-operation also comprises a screen capture statement;
the device further comprises:
and the second assignment unit is used for assigning values to the storage position variables of the screen capture functions by utilizing the target storage positions of the sub-operations to respectively obtain the screen capture sentences of the sub-operations, the target storage positions are used for storing the screen capture images obtained by executing the sub-operations, and the screen capture sentences are formed by the screen capture functions comprising the assigned storage position variables.
In a possible implementation manner, the image name of the screenshot image of each sub-operation is determined according to the order in the execution sequence of the sub-operations, the image name of the standard image of each sub-operation is the same as the image name of the screenshot image of the sub-operation, and the standard image of each sub-operation is stored in the target storage location of the sub-operation; the preset function further includes a comparison function, the comparison function includes a path variable, the apparatus further includes:
a third assignment unit, configured to assign a value to the image path for a target storage location of each sub-operation, to obtain a comparison statement;
the generating unit is used for generating a test script according to the script operation dependent statement, the execution statement of each sub-operation and the comparison statement, wherein the execution sequence of the comparison statement is later than that of the execution statement of each sub-operation.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
The embodiment of the application provides a test script generation device, which comprises a memory and more than one program, wherein the more than one program is stored in the memory, and the more than one program is configured to be executed by more than one processor and comprises the steps of carrying out the test script generation method in one or more embodiments.
FIG. 8 is a block diagram illustrating an apparatus 800 for test script generation in accordance with an exemplary embodiment. For example, test script generating device 800 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, and the like.
Referring to fig. 8, device 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communications component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
A power supply component 806 provides power to the various components of the device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, audio component 810 includes a Microphone (MIC) configured to receive external audio signals when device 800 is in an operational mode, such as a call mode, a record mode, and a voice information processing mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of components, such as a display and keypad of the device 800, the sensor assembly 814 may also search for changes in the position of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, orientation or acceleration/deceleration of the device 800, and temperature changes of the device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
Communications component 816 is configured to facilitate communications between device 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi,2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Further, it should be noted that: embodiments of the present application also provide a computer program product or computer program, which may include computer instructions, which may be stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor can execute the computer instruction, so that the computer device executes the description of the test script generation method in the embodiment corresponding to fig. 2, which is described above, and therefore, the description thereof will not be repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in the embodiments of the computer program product or the computer program referred to in the present application, reference is made to the description of the embodiments of the method of the present application.
It should be noted that, in the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the system or the device disclosed by the embodiment, the description is simple because the system or the device corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
The test script generation method, the test script generation device and the readable storage medium provided by the present application are introduced in detail, and specific examples are applied in the present document to explain the principle and the implementation of the present application, and the description of the above embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for generating a test script, the method comprising:
responding to a trigger operation aiming at a recording key, monitoring an execution operation executed by input equipment aiming at target software, and acquiring test data corresponding to the execution operation; the execution operation comprises at least one sub-operation; the test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations, wherein each sub-operation in the execution operation aims at;
acquiring a script operation dependent statement; the script operation dependent statement is used for defining a preset function and parameter variables included by the preset function; the preset function comprises a positioning function and an operation function, the positioning function comprises a position variable, and the operation function comprises an action variable;
analyzing the test data to obtain an operation parameter value of each sub-operation; the operating parameters comprise action parameters and position parameters;
assigning values to parameter variables included in the preset function by using the operation parameter values of each sub-operation to obtain an execution statement of each sub-operation;
and generating a test script according to the script operation dependent statement and the execution statement of each sub-operation, wherein the execution sequence of the execution statement of each sub-operation is determined according to the execution sequence among the sub-operations in the test data.
2. The method of claim 1, wherein the test data is recorded in a first data table, the first data table comprises one sub-operation for each row of test data, and the order of rows of test data in the first data table corresponds to the execution order between the sub-operations;
analyzing the test data to obtain an operation parameter value of each sub-operation, including:
analyzing the test data included in the first data table line by line in sequence, determining action parameter values corresponding to the operation parameters of the sub-operations according to the operation objects and the operation action types which are aimed at by the sub-operations corresponding to each line of test data, and determining position parameter values corresponding to the operation parameters of the sub-operations according to the operation positions of the sub-operations corresponding to each line of test data to obtain a first operation parameter table;
each row of data included in the first operation parameter table corresponds to one sub-operation, and each row of data includes an action parameter value and a position parameter value of the sub-operation; the row order of each row of data included in the first operation parameter list corresponds to an execution order among the respective sub-operations.
3. The method according to claim 1, wherein the step of respectively assigning values to parameter variables included in the preset function by using the operation parameter values of each of the sub-operations to obtain an execution statement of each of the sub-operations comprises:
assigning the action variable of the operation function by using the action parameter value of the sub-operation included in the first target data to obtain an action statement of the sub-operation corresponding to the first target data, wherein the action statement is composed of the operation function including the assigned action variable; the first target data is a row of data included in the first operation parameter table;
and assigning a value to the position variable of the positioning function by using the position parameter value of the sub-operation included in the first target data to obtain a position statement of the sub-operation corresponding to the first target data, wherein the position statement is composed of the positioning function including the assigned position variable.
4. The method of claim 1, wherein the test data further comprises a duration of an execution interval between two sub-operations that are sequentially adjacent in execution order; the preset function further comprises an interval duration function, and the interval duration function comprises a duration variable; the operating parameters further include an execution interval parameter; the test data are recorded in a second data table, each line of test data in the second data table corresponds to one sub-operation, and the sequence of each line of test data in the second data table corresponds to the execution sequence among the sub-operations;
analyzing the test data to obtain an operation parameter value of each sub-operation, including:
analyzing the test data included in the second data table line by line in sequence, determining action parameter values corresponding to the operation parameters of the sub-operations according to the operation objects and the operation action types which are aimed at by the sub-operations corresponding to each line of test data, determining position parameter values corresponding to the operation parameters of the sub-operations according to the operation positions of the sub-operations corresponding to each line of test data, and taking the execution interval duration between two sub-operations adjacent to the execution sequence as the execution interval parameter values of the sub-operations to obtain a second operation parameter table;
each row of data included in the second operation parameter table corresponds to one sub-operation, and each row of data includes an action parameter value, a position parameter value and an execution interval parameter value of the sub-operation; the execution interval parameter value is used for indicating the execution interval duration between the sub-operation and the next sub-operation adjacent to the execution sequence; the row order of each row of data included in the second operation parameter table corresponds to an execution order between the respective sub-operations.
5. The method according to claim 4, wherein the step of respectively assigning values to parameter variables included in the preset function by using the operation parameter values of each of the sub-operations to obtain an execution statement of each of the sub-operations comprises:
assigning values to the action variables of the operation functions by using the action parameter values of the sub-operations included in the second target data to obtain action statements of the sub-operations corresponding to the second target data, wherein the action statements are composed of the operation functions including the assigned action variables; the second target data is a row of data included in the second operation parameter table;
assigning a position variable of the positioning function by using a position parameter value of the sub-operation included in the second target data to obtain a position statement of the sub-operation corresponding to the second target data, wherein the position statement is composed of the positioning function including the assigned position variable;
and assigning values to the duration variables included in the interval duration function by using the execution interval parameter values of the sub-operations included in the second target data to obtain execution interval statements of the sub-operations corresponding to the second target data, wherein the execution interval statements are composed of the interval duration function including the assigned duration variables.
6. The method of claim 1, wherein the preset function further comprises a screen capture function, the screen capture function comprising a storage location variable; the execution statement of each sub-operation also comprises a screen capture statement;
before the running a dependent statement and an execution statement of each sub-operation according to the script and generating a test script, the method further includes:
and assigning values to storage position variables of the screen capture functions by using the target storage positions of the sub-operations to respectively obtain screen capture sentences of the sub-operations, wherein the target storage positions are used for storing the screen capture images obtained by executing the sub-operations, and the screen capture sentences are formed by the screen capture functions comprising the assigned storage position variables.
7. The method according to claim 6, wherein the image name of the screenshot image of each sub-operation is determined according to the order in the execution order of the sub-operations, the image name of the standard image of each sub-operation is the same as the image name of the screenshot image of the sub-operation, and the standard image of each sub-operation is stored in the target storage location of the sub-operation; the preset function further comprises a comparison function comprising a path variable, the method further comprising:
assigning the target storage position of each sub-operation to the image path to obtain a comparison statement;
the generating a test script according to the script running dependency statement and the execution statement of each sub-operation comprises:
and generating a test script according to the script operation dependent statement, the execution statement of each sub-operation and the comparison statement, wherein the execution sequence of the comparison statement is later than that of the execution statement of each sub-operation.
8. A test script generating apparatus, the apparatus comprising:
the first acquisition unit is used for responding to the triggering operation aiming at the recording key, monitoring the execution operation executed by the input equipment aiming at the target software and acquiring the test data corresponding to the execution operation; the execution operation comprises at least one sub-operation; the test data comprises an operation object, an operation action type, an operation position and an execution sequence among the sub-operations, wherein each sub-operation in the execution operation aims at;
the second acquisition unit is used for acquiring script operation dependent statements; the script operation dependent statement is used for defining a preset function and parameter variables included by the preset function; the preset function comprises a positioning function and an operation function, the positioning function comprises a position variable, and the operation function comprises an action variable;
the analysis unit is used for analyzing the test data to obtain an operation parameter value of each sub-operation; the operating parameters comprise action parameters and position parameters;
the first assignment unit is used for assigning the parameter variables included in the preset function respectively by using the operation parameter values of each sub-operation to obtain the execution statements of each sub-operation;
and the generating unit is used for generating a test script according to the script operation dependent statement and the execution statement of each sub-operation, and the execution sequence of the execution statement of each sub-operation is determined according to the execution sequence among the sub-operations in the test data.
9. A test script generating apparatus, comprising: a processor, a memory, a system bus;
the processor and the memory are connected through the system bus;
the memory to store one or more programs, the one or more programs comprising instructions, which when executed by the processor, cause the processor to perform the test script generation method of any of claims 1-7.
10. A computer-readable storage medium having stored therein instructions that, when run on a terminal device, cause the terminal device to perform the test script generation method of any one of claims 1-7.
CN202211288926.6A 2022-10-20 2022-10-20 Test script generation method, device, equipment and storage medium Pending CN115543831A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211288926.6A CN115543831A (en) 2022-10-20 2022-10-20 Test script generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211288926.6A CN115543831A (en) 2022-10-20 2022-10-20 Test script generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115543831A true CN115543831A (en) 2022-12-30

Family

ID=84735590

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211288926.6A Pending CN115543831A (en) 2022-10-20 2022-10-20 Test script generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115543831A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116701237A (en) * 2023-08-09 2023-09-05 北京集度科技有限公司 Test script generation and test method, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116701237A (en) * 2023-08-09 2023-09-05 北京集度科技有限公司 Test script generation and test method, equipment and storage medium
CN116701237B (en) * 2023-08-09 2023-12-29 北京集度科技有限公司 Test script generation and test method, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110134600B (en) Test script recording method, device and storage medium
CN110210219B (en) Virus file identification method, device, equipment and storage medium
CN104915290A (en) Application testing method and device
CN111274131A (en) Interface testing method and device, electronic equipment and storage medium
CN112241361A (en) Test case generation method and device and problem scene automatic reproduction method and device
CN108984417B (en) Software testing method, device, terminal and storage medium
CN115543831A (en) Test script generation method, device, equipment and storage medium
CN111427449A (en) Interface display method, device and storage medium
CN110795354A (en) Information processing method, device and storage medium
CN112416751A (en) Processing method and device for interface automation test and storage medium
CN111209195B (en) Method and device for generating test case
CN112559309A (en) Method and device for adjusting page performance acquisition algorithm
CN112256563A (en) Android application stability testing method and device, electronic equipment and storage medium
CN104765686B (en) The method and device of test application program
CN113778687B (en) Memory allocation information processing method and device, electronic equipment and storage medium
CN106354595B (en) Mobile terminal, hardware component state detection method and device
CN112383661B (en) Mobile terminal automatic test method and device, electronic equipment and storage medium
CN111240927B (en) Method, device and storage medium for detecting time consumption of method in program
CN109684525B (en) Document display method and device, storage medium and test equipment
CN115357519B (en) Test method, device, equipment and medium
CN112631695A (en) Data verification method and device, electronic equipment and storage medium
CN112988304A (en) Recording method and device of operation mode, electronic equipment and storage medium
CN111309613A (en) Application testing method, device, equipment and computer readable storage medium
CN115629974A (en) Software testing method, device, equipment and medium
CN113806227B (en) Information processing method, device, electronic equipment and storage medium

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