Method and device for generating test script code

By generating test script code, the corresponding relationship between pre-stored operations and operation code templates is used to automatically generate test script code, which solves the problem that testers need to manually write test script code in the existing technology, and improves the efficiency of automated testing purpose.

CN112052167BActive Publication Date: 2025-02-25BEIJING PHOENIX AUTO INTELLIGENCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010868538.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-25
Publication Date
2025-02-25
Estimated Expiration
2040-08-25

AI Technical Summary

Technical Problem

In the prior art, automated testing still requires testers to write test script code, resulting in a long time consumption and inefficiency.

Method used

By receiving script establishment requests, displaying options for multiple operations, and determining the target operation code template corresponding to the target operation based on the corresponding relationship between the pre-stored operation and the operation code template, generating operation code segments and test script codes.

Benefits of technology

No need for testers to manually write test script code, saving time and improving efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112052167B_ABST
    Figure CN112052167B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for generating test script code, belonging to the field of software testing technology. The method comprises: receiving a script establishment request, and displaying multiple operation options; when receiving a trigger instruction of an option of a target operation among the multiple operations, determining a target operation code template corresponding to the target operation based on a correspondence between pre-stored operations and operation code templates; obtaining an identifier of an operation object corresponding to the input target operation; generating an operation code segment based on the identifier of the operation object and the target operation code template; and generating a test script code based on the operation code segment. With the present application, testers do not need to manually write test script codes, which saves time and improves efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a method and device for generating test script codes. Background Art

[0002] Automated testing is a process that converts manual test behavior into machine execution. Usually, after designing a test case and passing the review, the tester will perform the test step by step according to the procedures described in the test case to compare the actual results with the expected results. In this process, in order to save manpower, time or hardware resources and improve testing efficiency, the concept of automated testing was introduced.

[0003] In the related art, automated testing is performed, and testers write corresponding test script codes based on test cases. The test script codes are used to simulate human operations on the application program to implement testing of the application program.

[0004] Although this type of automated testing saves manpower and improves efficiency compared to manual testing, it requires testers to write corresponding test script codes, so it still takes a long time and the efficiency is still low. Summary of the invention

[0005] The embodiment of the present application provides a method for generating test script codes, which can solve the problem that in the prior art, automated testing still requires testers to write corresponding test script codes, which still takes a long time and has low efficiency. The technical solution is as follows:

[0006] In a first aspect, a method for generating a test script code is provided, the method comprising:

[0007] Receive script creation request and display multiple operation options;

[0008] When receiving a trigger instruction of an option of a target operation among the multiple operations, determining a target operation code template corresponding to the target operation based on a pre-stored correspondence between operations and operation code templates;

[0009] Get the identifier of the operation object corresponding to the input target operation;

[0010] Generate an operation code segment based on the identifier of the operation object and the target operation code template;

[0011] Generate test script code based on the operation code segment.

[0012] In a possible design, based on the identifier of the operation object and the target operation code template, before generating the operation code segment, the following is further included:

[0013] Get the input value corresponding to the input target operation;

[0014] The step of generating an operation code segment based on the identifier of the operation object and the target operation code template includes:

[0015] An operation code segment is generated based on an input value corresponding to the target operation, an identifier of the operation object, and a target operation code template.

[0016] In a possible design, the generating of the operation code segment based on the input value corresponding to the target operation, the identifier of the operation object and the target operation code template includes:

[0017] Acquire a first insertion position and a second insertion position corresponding to a pre-stored target operation code template;

[0018] In the target operation code template, the identifier of the operation object is inserted into the first insertion position, and the input value corresponding to the target operation is inserted into the second insertion position to generate an operation code segment.

[0019] In a possible design, before generating the test script code based on the operation code segment, the following is also included:

[0020] Get the target parameter name and the corresponding benchmark parameter value for the input result test;

[0021] Generate a result verification code segment based on a pre-stored result verification code template, a target parameter name, and a corresponding benchmark parameter value;

[0022] Generate test script code based on the operation code segment, including:

[0023] Generate test script code based on the operation code segment and the result verification code segment.

[0024] In a possible design, a result verification code segment is generated based on a pre-stored result verification code template, a target parameter name, and a corresponding benchmark parameter value, including:

[0025] Obtain a third insertion position and a fourth insertion position corresponding to a pre-stored result verification code template;

[0026] In the target operation code template, the target parameter name is inserted into the third insertion position, and the reference parameter value is inserted into the fourth insertion position to generate a result verification code segment.

[0027] In a possible design, after generating the test script code based on the operation code segment, the following is also included:

[0028] Run the test script code, test the target application, and output the test results.

[0029] In one possible design, the operations include a clicking operation, a sliding operation, and a data input operation.

[0030] In a second aspect, a device for generating a test script code is provided, the device comprising:

[0031] A display module, used for receiving a script creation request and displaying multiple operation options;

[0032] a determination module, configured to, when receiving a trigger instruction of an option of a target operation among the multiple operations, determine a target operation code template corresponding to the target operation based on a pre-stored correspondence between operations and operation code templates;

[0033] An acquisition module, used to acquire an identifier of an operation object corresponding to the input target operation;

[0034] A generating module is used to generate an operation code segment based on the identifier of the operation object and the target operation code template; and to generate a test script code based on the operation code segment.

[0035] In a possible design, the acquisition module is further used to:

[0036] Obtaining an input value corresponding to the target operation input;

[0037] The generating module is used for:

[0038] An operation code segment is generated based on an input value corresponding to the target operation, an identifier of the operation object, and the target operation code template.

[0039] In a possible design, the generating module is used to:

[0040] Acquire a first insertion position and a second insertion position corresponding to the pre-stored target operation code template;

[0041] In the target operation code template, the identifier of the operation object is inserted into the first insertion position, and the input value corresponding to the target operation is inserted into the second insertion position to generate an operation code segment.

[0042] In a possible design, the acquisition module is further used to:

[0043] Get the target parameter name and the corresponding benchmark parameter value for the input result test;

[0044] Generate a result verification code segment based on a pre-stored result verification code template, the target parameter name and the corresponding benchmark parameter value;

[0045] The generating module is used for:

[0046] A test script code is generated based on the operation code segment and the result verification code segment.

[0047] In a possible design, the generating module is used to:

[0048] Obtaining a third insertion position and a fourth insertion position corresponding to the pre-stored result verification code template;

[0049] In the target operation code template, the target parameter name is inserted into the third insertion position, and the reference parameter value is inserted into the fourth insertion position to generate a result verification code segment.

[0050] In one possible design, the device further includes:

[0051] The running module is used to run the test script code, test the target application program, and output the test results.

[0052] In one possible design, the operation includes a clicking operation, a sliding operation, and a data input operation.

[0053] In a third aspect, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the operation performed by the method for generating test script code.

[0054] In a fourth aspect, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the instruction is loaded and executed by a processor to implement the operations performed by the method for generating test script code.

[0055] The beneficial effect brought about by the technical solution provided in the embodiment of the present application is: the solution mentioned in the embodiment of the present application can generate an operation code segment based on the identification of the operation object and the operation code template, and then generate a test script code, and does not require the tester to manually write the test script code, saving time and improving efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0057] Figure 1 It is a schematic diagram of an implementation environment provided by an embodiment of the present application;

[0058] Figure 2 It is a flow chart of a method for generating test script code provided by an embodiment of the present application;

[0059] Figure 3 This is a schematic diagram of an interface display provided in an embodiment of the present application;

[0060] Figure 4 This is a schematic diagram of an interface display provided in an embodiment of the present application;

[0061] Figure 5 It is a structural schematic diagram of a device for generating test script code provided in an embodiment of the present application;

[0062] Figure 6 It is a structural block diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION

[0063] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0064] The embodiment of the present application provides a method for generating a test script code, which can be implemented by a computer device, which can be a desktop computer, a notebook computer, a tablet computer, a mobile phone, etc.

[0065] The computer device may include a processor, a memory, an input component, an output component, a communication component, etc. The memory may be various non-volatile storage devices or volatile storage devices, and may be used for data storage, for example, data of the test application, pre-stored data for generating the test script code, intermediate data generated in the process of generating the test script code, the generated test script code, data transmitted in the process of running the test script code, etc. The processor may be used to run the test application, process the test script code generation process, run the test script code to test the application under test, etc. The input component may include a mouse, a keyboard, a touch pad, a handwriting board, a microphone, etc., for obtaining data input by the tester. The output component may include an image output component, an audio output component, a vibration output component, etc. The image output component may be used to display the interface of the test application so that the tester can operate, and may also display the interface of the application under test during the test, and may also display the test results. The audio output component and the vibration output component may be used to output some prompt signals.

[0066] A test application (also referred to as a test platform) is installed in the computer device, and the test application is used to test the application under test in the computer device or the application under test in other devices connected to the computer device. The embodiment of the present application takes the test application testing the application under test on the vehicle terminal device as an example to illustrate the scheme, and other situations are similar to them, and this embodiment will not be repeated. Figure 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application. Figure 1 The computer device establishes a communication connection with the vehicle terminal device, which can be a wired communication connection or a wireless communication connection. The vehicle terminal device is installed with system programs and various applications, which can all be tested applications. The tester can operate the test application on the computer device to generate the corresponding test script code, run the test script code to generate the test results for display.

[0067] Figure 2 This is a flow chart of a method for generating test script code provided by an embodiment of the present application. Figure 2 , the embodiment comprises:

[0068] 201. Receive a script creation request and display multiple operation options.

[0069] The operation is an operation in the application under test. The operation may include a click operation, a slide operation, and a data input operation. In addition, the operation may also include a long press operation, a double-click operation, a click and slide to a target position, and the like, which is not limited in the embodiments of the present application.

[0070] In implementation, when the tester is ready to test an application in the vehicle-mounted terminal device, he can first establish a communication connection between the computer device and the vehicle-mounted terminal device, for example, he can connect the computer device to the vehicle-mounted terminal device through a data cable. Then, the tester can run the test application in the computer device and enter the main interface of the test application. In the main interface of the test application, there is an option to add an item. The tester clicks on this option to trigger the display of a list of other devices to which the computer device is connected, including the above-mentioned vehicle-mounted terminal device. After the tester selects the vehicle-mounted terminal device, the display of the application list can be triggered, and the application list includes the various applications installed on the vehicle-mounted terminal device. The tester selects the application to be tested to complete the project addition. Then, the tester clicks on the added item to trigger the display of the script code establishment interface, which displays various possible operation options in the application to be tested, such as options for click operations, options for sliding operations, and options for data input operations.

[0071] 202. When a trigger instruction of an option of a target operation among multiple operations is received, a target operation code template corresponding to the target operation is determined based on a pre-stored correspondence between operations and operation code templates.

[0072] The operation code template is a part of the code that performs an operation in the test script code, which can be obtained by removing some parameter values ​​from the code of the operation. The removed parameter values ​​may include the identifier of the operation object and the input value corresponding to the operation (for example, the operation is an input operation). Each operation pre-stored in the test application corresponds to a corresponding operation code template.

[0073] In implementation, relevant technicians can pre-write operation code templates corresponding to each different operation, store the operation identifiers and operation code templates in a corresponding correspondence table, as shown in Table 1 below, and add this correspondence table to the test application.

[0074] Table 1

[0075] Operation ID Action code template Click action identifier Template M1 Slide operation indicator Template M2 Identification of data entry operations Template M3

[0076] The tester clicks to select a target operation in the script code creation interface, which can trigger the computer device to obtain the identifier of the target operation, and search and obtain the corresponding operation code template in the corresponding relationship table based on the identifier of the target operation.

[0077] 203. Obtain an identifier of an operation object corresponding to the input target operation.

[0078] The operation object is the corresponding operation object of the target operation in the application under test, which can be a control, an input box, etc. For example, the operation object of a click operation or a slide operation can be a control, and the operation object of a data input operation can be an input box.

[0079] In implementation, the tester clicks and selects a target operation in the script code creation interface to trigger the display of the parameter input window, such as Figure 3 As shown, the parameter input window is provided with input boxes for the names of the parameters that need to be filled in the operation code template and the corresponding parameter values.

[0080] Testers can use third-party applications to extract the identifiers of operating objects such as controls and input boxes in the tested application of the vehicle terminal device. Figure 3For the parameter input window, the tester can click the "Get control, input box ID (Identity Document, identity identification number)" button in the upper right corner to display the synchronization window through the third-party application embedded in this test application, in which the display content of the vehicle terminal device is synchronized. In the synchronization window, the tester can click on a control or input box, thereby triggering the display of the identifier of this control or input box. At this time, the tester can copy the identifier and then paste it into the input box corresponding to the operation object identifier in the above parameter input window, so that the test application can obtain the identifier of the operation object corresponding to the target operation.

[0081] In the above process, the third-party application is embedded in the test application, or the third-party application can be independent of the test application. In the above process, the tester manually inputs the identifier of the operation object into the corresponding input box, and the test application can also directly obtain the identifier of the operation object extracted by the third-party application.

[0082] Optionally, the target operation in the application under test may also involve input values, such as data input operations. Before performing subsequent steps, in addition to obtaining the identifier of the operation object corresponding to the input target operation, the input value corresponding to the input target operation may also be obtained.

[0083] The input value is data input into the input box of the application under test, and the input value is input into the corresponding input box of the application under test by the test script code during the running of the test script code.

[0084] In implementation, for operations that require data input, in the parameter input window, in addition to displaying an input box corresponding to the identifier of the operation object, an input box corresponding to the input value is also displayed, such as Figure 3 As shown. Testers can consider the input values ​​required for the current test in advance, and then enter the input values ​​into the input boxes corresponding to the above input values, and then test the application to obtain the input values ​​corresponding to the target operation. For example, a test process tests the search bar, the operation is to input data, and the input value can be a keyword, such as "car", and then the tester enters "car" into the corresponding input box, and then the test application obtains the input value corresponding to the target operation.

[0085] 204. Generate an operation code segment based on the identifier of the operation object and the target operation code template.

[0086] Among them, the operation code segment is the code for performing an operation during the test process, and the test script code can be composed of one or more operation code segments. The operation code segment can be considered as the most basic code unit that constitutes the test script code. Some higher-level code units can be included in the test script code, and the high-level code units can be composed of low-level code units. For example, some high-level code units will be mentioned below, including Story, Step, Scenario, etc. Story can be composed of one or more operation code segments, Step can be composed of one or more operation code segments and / or Story, and Scenario can be composed of one or more operation code segments, Story, and Step.

[0087] During implementation, after the tester enters the corresponding parameter value in the parameter input window, he clicks the "OK" button at the bottom of the window. This will trigger the insertion of the parameter value obtained in the parameter input window into the specified position in the target operation code template to generate an operation code segment.

[0088] Optionally, for the case where the above-mentioned target operation includes an input value, the input value is also required when generating an operation code segment, and the corresponding step 204 can be processed as follows: based on the input value corresponding to the target operation, the identifier of the operation object and the target operation code template, generate an operation code segment.

[0089] In implementation, when writing an operation code template, the relevant technicians will leave the specified parameter value blank in the operation code template, and will record the blank position as the position for inserting the parameter value in the operation code template when subsequently generating the operation code segment, wherein the blank position may include the first insertion position corresponding to the identifier of the operation object, and may also include the second insertion position corresponding to the input value of the operation. Then, the identifier of the operation, the operation code template, the first insertion position, and the second insertion position may be stored in a correspondence table, as shown in Table 2 below, and this correspondence table may be added to the test application.

[0090] Table 2

[0091] Operation ID Action code templates First insertion position Second insertion position Click action identifier Template M1 Position A1 Position B1 Slide operation indicator Template M2 Position A2 Position B2 Identification of data entry operations Template M3 Position A3 Position B3

[0092] In implementation, after the tester fills the identifier of the operation object corresponding to the target operation and the input value corresponding to the target operation into the corresponding input box, he clicks the "OK" button below the parameter input value, which can trigger the test application to search in the above correspondence table to obtain the first insertion position and the second insertion position corresponding to the pre-stored target operation code template. Then, in the target operation code template, the identifier of the operation object is inserted into the first insertion position, and the input value corresponding to the target operation is inserted into the second insertion position to generate the operation code segment.

[0093] Optionally, the test script code may include a result verification code segment in addition to the operation code segment. Accordingly, before generating the test script code, it is also necessary to generate a result verification code segment. The processing process may be as follows: obtain the input target parameter name and the corresponding benchmark parameter value for the result test; based on the pre-stored result verification code template, target parameter name and the corresponding benchmark parameter value, generate a result verification code segment.

[0094] The result verification code template is a code in the test script code used to perform result verification operations, and can be obtained by removing the target parameter name and the corresponding benchmark parameter value from the complete code for result verification.

[0095] The target parameter name is the parameter name of the parameter that needs to be verified during the test. The benchmark parameter value is the correct parameter value that the parameter that needs to be verified should reach after the operation on the application under test in the test script code is executed. The tester can determine the parameter that needs to be verified based on the operation object of the target operation. For example, a test process tests the volume increase control, the corresponding operation object is the volume increase control, and the operation is a click operation. Then, the parameter that needs to be verified is the volume increase value, and the benchmark parameter value can be 1. This operation is determined based on the operation object of the target operation and the test requirements of the tester, and the embodiments of the present application do not limit this.

[0096] In implementation, when relevant technicians write the result verification code template, they will leave the target parameter name and the corresponding reference parameter value blank in the result verification code template, and they will record the blank position as the position to insert the target parameter name and the corresponding reference parameter value in the result verification code template when subsequently generating the result verification code segment, wherein the blank position may include the third insertion position corresponding to the target parameter name and the fourth insertion position corresponding to the reference parameter value. Then, the result verification code template, the third insertion position and the fourth insertion position may be stored in the test application program accordingly.

[0097] In the script code creation interface, there is also a result verification code segment creation option. When the tester clicks the result verification code segment creation option, a parameter input window for creating a result verification code segment can be triggered, such as Figure 4As shown, the parameter input window may include input boxes for parameter names and benchmark parameter values. If there is only one parameter to be verified, the parameter input window may include an input box for a parameter name and a benchmark parameter value. If there are multiple parameters to be verified, the parameter input window may include input boxes for multiple parameter names and multiple benchmark parameter values. The tester may input the target parameter name and the corresponding benchmark parameter value into the corresponding input box, and then click the "OK" button below the parameter input window. At this time, the computer device may be triggered to obtain the target parameter name and benchmark parameter value entered by the tester in the parameter input window, and obtain the stored result verification code template and the corresponding third insertion position and fourth insertion position, insert the target parameter name into the third insertion position of the result verification code template, and insert the benchmark parameter value into the fourth insertion position of the result verification code template to obtain the result verification code segment.

[0098] 205. Generate test script code based on the generated at least one operation code segment.

[0099] Optionally, a test script code may be generated based on the operation code segment and the result verification code segment.

[0100] In implementation, after the operation code segment and the result verification code segment are edited, the computer device can automatically generate the test script code based on the operation code segment and the result verification code segment. Alternatively, a generate test script code option is provided in the script code establishment interface, and after the tester completes the editing of the operation code segment and the result verification code segment, the tester can click the generate test script code option, which can trigger the computer device to generate the test script code based on the operation code segment and the result verification code segment.

[0101] Optionally, after the test script code is generated, the test script code may be run to test the target application and output the test result. The target application is the application under test.

[0102] In implementation, a run test option is set in the test application. After the tester clicks the run test option, a script selection window can be triggered. The tester can select the generated test script code in the script selection window, and then the computer device can be triggered to execute the selected test script code. In the process of executing the test script code, the test script code will trigger the computer device to send control instructions to the vehicle terminal device based on the code content and AOP (Aspect Oriented Programming) to simulate human operation of the vehicle terminal device. After all operations are completed, the actual parameter value corresponding to the target parameter name in the vehicle terminal device is obtained, and the actual parameter value is compared with the benchmark parameter value. If they are the same, a prompt message of "test passed" is displayed in the test application. If they are different, a prompt message of "test failed" is displayed in the test application.

[0103] The following is a detailed description of the situation where there are multiple levels of code units (ie, the above-mentioned Story, Step, Scenario) in the test script code.

[0104] After the tester completes adding the project, the script code creation interface of the test application is displayed on the computer device. The script code creation interface is provided with buttons such as "Generate Story", "Generate Step", "Generate Scenario", "Result Verification" and "Run Script Code".

[0105] First, the tester can click the "Generate Story" button to trigger the display of the Story window with the "Generate Operation Code Segment" button, click the "Generate Operation Code Segment" button to trigger the display of the window with buttons such as "Click Operation", "Slide Operation", and "Data Input Operation", click any operation button to trigger the display of the parameter input window, and the tester obtains the parameter value of the corresponding parameter and enters it into the input box corresponding to the parameter input window, clicks the "OK" button below the parameter input window to generate the operation code segment, at this time, the generated operation code segment is automatically stored in the computer device, the parameter input window is automatically closed, and returns to the Story window, and the schematic icon of the operation code segment can be displayed in the Story window. It is understandable that the tester can repeat the above operation to obtain multiple operation code segments of different operations. At this time, the Story window can display the schematic icons of all generated operation code segments, and click the "Generate Story" button below the window, then the Story is generated based on all the operation code segments and stored in the computer device. The tester can repeat the above operation to generate multiple different Stories.

[0106] Then, the tester can click the "Generate Step" button in the script code creation interface to trigger the Step window that displays the "Add Story" button and the "Generate Operation Code Segment" button. The tester clicks the "Add Story" button to trigger the display of the Story list, which displays all the created Stories. The tester can click to select any Story to add to the Step. The tester can also click the "Generate Operation Code Segment" button to generate the operation code segment. The operation of generating the operation code segment is similar to the above and will not be repeated here. The Step window can display the schematic icon of the Story selected by the tester and the schematic icon of the operation code segment generated by the tester in the Step window. Then the tester can click the "Generate Step" button at the bottom of the window to generate the Step based on the Story and operation code segment corresponding to all the schematic icons in the Step window, and store it in the computer device. The tester can repeat the above operations to generate multiple different Steps.

[0107] Then, the tester can click the "Generate Scenario" button in the script code creation interface to trigger the Scenario window with the "Add Step" button and the "Generate Operation Code Segment" button. The tester clicks the "Add Step" button to trigger the display of the Step list, which displays all the created Steps. The tester can click and select any Step to add to the Scenario. The tester can also click the "Generate Operation Code Segment" button to generate an operation code segment. The operation of generating an operation code segment is similar to the above and will not be repeated here. The Scenario window can display the schematic icon of the Step selected by the tester and the schematic icon of the operation code segment generated by the tester in the Scenario window. Then the tester can click the "Generate Scenario" button at the bottom of the window to generate a Scenario based on the Step and operation code segment corresponding to all the schematic icons in the Scenario window, and store it in the computer device. The tester can repeat the above operation to generate multiple different Senarios.

[0108] Then, the tester can click the "Result Verification" button in the script code creation interface to trigger the display of the Scenario list, which displays all the created Scenarios. The tester can click to select any Scenario, which will trigger the display of the parameter input window with parameter names, benchmark parameter values ​​and their corresponding input boxes. After the tester obtains the corresponding parameter name and benchmark parameter value and enters it into the corresponding input box, click the "OK" button at the bottom of the window to trigger the generation of the result verification code segment for the above selected Scenario, and obtain the test script code corresponding to the Scenario.

[0109] When conducting a test, the tester can select a Scenario and run the corresponding test script code.

[0110] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.

[0111] The solution mentioned in the embodiment of the present application can generate an operation code segment based on the identification of the operation object and the operation code template, and then generate a test script code. There is no need for the tester to manually write the test script code, which saves time and improves efficiency.

[0112] The present application embodiment provides a device for generating a test script code, which may be the computer device in the above embodiment, such as Figure 5 As shown, the device comprises:

[0113] Display module 510, used to receive a script creation request and display multiple operation options;

[0114] The determination module 520 is configured to determine, when receiving a trigger instruction of an option of a target operation among the multiple operations, a target operation code template corresponding to the target operation based on a pre-stored correspondence between operations and operation code templates;

[0115] An acquisition module 530 is used to acquire an identifier of an operation object corresponding to the input target operation;

[0116] The generating module 540 is used to generate an operation code segment based on the identifier of the operation object and the target operation code template; and to generate a test script code based on the operation code segment.

[0117] In a possible design, the acquisition module 530 is further used to:

[0118] Obtaining an input value corresponding to the target operation input;

[0119] The generating module 540 is used to:

[0120] An operation code segment is generated based on an input value corresponding to the target operation, an identifier of the operation object, and the target operation code template.

[0121] In one possible design, the generating module 540 is used to:

[0122] Acquire a first insertion position and a second insertion position corresponding to the pre-stored target operation code template;

[0123] In the target operation code template, the identifier of the operation object is inserted into the first insertion position, and the input value corresponding to the target operation is inserted into the second insertion position to generate an operation code segment.

[0124] In a possible design, the acquisition module 530 is further used to:

[0125] Get the target parameter name and the corresponding benchmark parameter value for the input result test;

[0126] Generate a result verification code segment based on a pre-stored result verification code template, the target parameter name and the corresponding benchmark parameter value;

[0127] The generating module 540 is used to:

[0128] A test script code is generated based on the operation code segment and the result verification code segment.

[0129] In one possible design, the generating module 540 is used to:

[0130] Obtaining a third insertion position and a fourth insertion position corresponding to the pre-stored result verification code template;

[0131] In the target operation code template, the target parameter name is inserted into the third insertion position, and the reference parameter value is inserted into the fourth insertion position to generate a result verification code segment.

[0132] In one possible design, the device further includes:

[0133] The running module is used to run the test script code, test the target application program, and output the test results.

[0134] In one possible design, the operation includes a clicking operation, a sliding operation, and a data input operation.

[0135] It should be noted that: the device for generating test script code provided in the above embodiment only uses the division of the above functional modules as an example when triggering the generation of test script code. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device for generating test script code provided in the above embodiment and the method embodiment for generating test script code belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0136] Figure 6 The structural block diagram of a terminal 600 provided by an exemplary embodiment of the present application is shown. The terminal may be the computer device in the above-mentioned embodiment. The terminal 600 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), an MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) player, a laptop computer or a desktop computer. The terminal 600 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.

[0137] Typically, the terminal 600 includes a processor 601 and a memory 602 .

[0138] The processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 601 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 601 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 601 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0139] The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 602 is used to store at least one instruction, which is used to be executed by the processor 601 to implement the method for generating test script code provided in the method embodiment of the present application.

[0140] In some embodiments, the terminal 600 may further optionally include: a peripheral device interface 603 and at least one peripheral device. The processor 601, the memory 602 and the peripheral device interface 603 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 603 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 604, a touch display screen 605, a camera 606, an audio circuit 607, a positioning component 608 and a power supply 609.

[0141] The peripheral device interface 603 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 601 and the memory 602. In some embodiments, the processor 601, the memory 602, and the peripheral device interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral device interface 603 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.

[0142] The radio frequency circuit 604 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 604 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 604 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 604 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 604 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 604 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.

[0143] The display screen 605 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos and any combination thereof. When the display screen 605 is a touch display screen, the display screen 605 also has the ability to collect touch signals on the surface or above the surface of the display screen 605. The touch signal can be input to the processor 601 as a control signal for processing. At this time, the display screen 605 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 605 can be one, and the front panel of the terminal 600 is set; in other embodiments, the display screen 605 can be at least two, which are respectively set on different surfaces of the terminal 600 or are folded; in some other embodiments, the display screen 605 can be a flexible display screen, which is set on the curved surface or folded surface of the terminal 600. Even, the display screen 605 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 605 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).

[0144] The camera assembly 606 is used to capture images or videos. Optionally, the camera assembly 606 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 606 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0145] The audio circuit 607 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 601 for processing, or input them into the radio frequency circuit 604 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 600. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 601 or the radio frequency circuit 604 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 607 may also include a headphone jack.

[0146] Positioning component 608 is used to locate the current geographical location of terminal 600 to implement navigation or LBS (Location Based Service). Positioning component 608 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system, Russia's Grenas system or the European Union's Galileo system.

[0147] The power supply 609 is used to power various components in the terminal 600. The power supply 609 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 609 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0148] In some embodiments, the terminal 600 further includes one or more sensors 610 , including but not limited to: an acceleration sensor 611 , a gyroscope sensor 612 , a pressure sensor 613 , a fingerprint sensor 614 , an optical sensor 615 , and a proximity sensor 616 .

[0149] The acceleration sensor 611 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 600. For example, the acceleration sensor 611 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 601 can control the touch display screen 605 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 611. The acceleration sensor 611 can also be used for collecting game or user motion data.

[0150] The gyro sensor 612 can detect the body direction and rotation angle of the terminal 600, and the gyro sensor 612 can cooperate with the acceleration sensor 611 to collect the user's 3D actions on the terminal 600. The processor 601 can implement the following functions based on the data collected by the gyro sensor 612: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0151] The pressure sensor 613 can be set on the side frame of the terminal 600 and / or the lower layer of the touch display screen 605. When the pressure sensor 613 is set on the side frame of the terminal 600, it can detect the user's holding signal of the terminal 600, and the processor 601 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 613. When the pressure sensor 613 is set on the lower layer of the touch display screen 605, the processor 601 controls the operability controls on the UI interface according to the user's pressure operation on the touch display screen 605. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0152] The fingerprint sensor 614 is used to collect the user's fingerprint, and the processor 601 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 614, or the fingerprint sensor 614 identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 601 authorizes the user to perform relevant sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. The fingerprint sensor 614 can be set on the front, back, or side of the terminal 600. When a physical button or a manufacturer logo is set on the terminal 600, the fingerprint sensor 614 can be integrated with the physical button or the manufacturer logo.

[0153] The optical sensor 615 is used to collect the ambient light intensity. In one embodiment, the processor 601 can control the display brightness of the touch display screen 605 according to the ambient light intensity collected by the optical sensor 615. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 605 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 605 is reduced. In another embodiment, the processor 601 can also dynamically adjust the shooting parameters of the camera assembly 606 according to the ambient light intensity collected by the optical sensor 615.

[0154] The proximity sensor 616, also called a distance sensor, is usually arranged on the front panel of the terminal 600. The proximity sensor 616 is used to collect the distance between the user and the front of the terminal 600. In one embodiment, when the proximity sensor 616 detects that the distance between the user and the front of the terminal 600 is gradually decreasing, the processor 601 controls the touch display screen 605 to switch from the screen-on state to the screen-off state; when the proximity sensor 616 detects that the distance between the user and the front of the terminal 600 is gradually increasing, the processor 601 controls the touch display screen 605 to switch from the screen-off state to the screen-on state.

[0155] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on the terminal 600, and the terminal 600 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0156] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including instructions, and the instructions can be executed by a processor in a terminal to complete the method of generating test script code in the above embodiment. The computer-readable storage medium can be non-transient. For example, the computer-readable storage medium can be a ROM (Read-Only Memory), a RAM (Random Access Memory), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0157] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0158] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for generating a test script code, characterized in that: The method comprises: Establishing a communication connection between the computer device and the vehicle terminal, entering the main interface of the test application, the main interface of the test application is provided with an option to add an item, in response to clicking the option, triggering the display of a list of other devices to which the computer device is connected, the list of other devices including the vehicle terminal, in response to the selection of the vehicle terminal in the device list, displaying an application list, the application list including applications installed on the vehicle terminal device, completing the addition of the item in response to the selection of the application under test in the application list, triggering the display of a script code establishment interface in response to clicking the added item, the script code display establishment interface displaying options for multiple operations in the application under test; When receiving a trigger instruction of an option of a target operation among the multiple operations, determining a target operation code template corresponding to the target operation based on a pre-stored correspondence between operations and operation code templates; In response to a click on the target operation in the script code establishment interface, a parameter input window is triggered to be displayed, wherein the parameter input window is provided with the name of the parameter to be filled in the operation code template, an input box of the corresponding parameter value and an acquisition control, and an input box ID button; in response to a click on the acquisition control and the input box ID button, a synchronization window is displayed; in response to a click on an operation object in the synchronization window, an identifier of the operation object is displayed, the operation object is a corresponding operation object of the target operation in the application under test; in response to a copy of the identifier of the operation object, an identifier of the operation object corresponding to the target operation is acquired; generating an operation code segment based on the identifier of the operation object and the target operation code template; Obtain the target parameter name and the corresponding reference parameter value input for the result test, wherein the target parameter name is the parameter name of the parameter that needs to be verified during the test, and the reference parameter value is the correct parameter value that the parameter that needs to be verified should reach; Generate a result verification code segment based on a pre-stored result verification code template, the target parameter name and the corresponding benchmark parameter value; Generate a test script code based on the operation code segment and the result verification code segment; Running the test script code to test the application under test; Obtain the actual parameter value corresponding to the target parameter name, compare the actual parameter value with the reference parameter value, and if they are the same, display a prompt message of "test passed"; if they are different, display a prompt message of "test failed".

2. The method according to claim 1, characterized in that: Before generating the operation code segment based on the identifier of the operation object and the target operation code template, the method further includes: Obtaining an input value corresponding to the target operation input; The generating the operation code segment based on the identifier of the operation object and the target operation code template comprises: An operation code segment is generated based on the input value corresponding to the target operation, the identifier of the operation object and the target operation code template.

3. The method according to claim 2, characterized in that The generating the operation code segment based on the input value corresponding to the target operation, the identifier of the operation object and the target operation code template includes: Acquire a first insertion position and a second insertion position corresponding to the pre-stored target operation code template; In the target operation code template, the identifier of the operation object is inserted into the first insertion position, and the input value corresponding to the target operation is inserted into the second insertion position to generate an operation code segment.

4. The method according to claim 1, characterized in that The generating of the result verification code segment based on the pre-stored result verification code template, the target parameter name and the corresponding reference parameter value comprises: Obtaining a third insertion position and a fourth insertion position corresponding to the pre-stored result verification code template; In the target operation code template, the target parameter name is inserted into the third insertion position, and the reference parameter value is inserted into the fourth insertion position to generate a result verification code segment.

5. The method according to claim 1, characterized in that The operations include a click operation, a slide operation, and a data input operation.

6. A device for generating test script code, characterized in that: The device comprises: A display module is used to establish a communication connection between the computer device and the vehicle terminal, enter the main interface of the test application, the main interface of the test application is provided with an option to add an item, in response to clicking the option, trigger the display of a list of other devices to which the computer device is connected, the list of other devices includes the vehicle terminal, in response to the selection of the vehicle terminal in the device list, display an application list, the application list includes applications installed on the vehicle terminal device, in response to the selection of the tested application in the application list, complete the addition of the item, in response to clicking the added item, trigger the display of a script code establishment interface, the display script code establishment interface displays options for multiple operations in the tested application; a determination module, configured to, when receiving a trigger instruction of an option of a target operation among the multiple operations, determine a target operation code template corresponding to the target operation based on a pre-stored correspondence between operations and operation code templates; an acquisition module, for triggering the display of a parameter input window in response to a click on the target operation in the script code establishment interface, wherein the parameter input window is provided with the name of the parameter to be filled in the operation code template, an input box of the corresponding parameter value, an acquisition control, and an input box ID button; in response to a click on the acquisition control and the input box ID button, a synchronization window is displayed; in response to a click on an operation object in the synchronization window, an identifier of the operation object is displayed, the operation object being the corresponding operation object of the target operation in the application under test; and in response to the copying of the identifier of the operation object, an identifier of the operation object corresponding to the target operation is acquired; A generation module is used to generate an operation code segment based on the identifier of the operation object and the target operation code template; obtain the input target parameter name and the corresponding benchmark parameter value for result testing, wherein the target parameter name is the parameter name of the parameter that needs to be verified during the test, and the benchmark parameter value is the correct parameter value that the parameter that needs to be verified should reach; generate a result verification code segment based on a pre-stored result verification code template, the target parameter name and the corresponding benchmark parameter value; generate a test script code based on the operation code segment and the result verification code segment; run the test script code to test the application under test; obtain the actual parameter value corresponding to the target parameter name, compare the actual parameter value with the benchmark parameter value, and if they are the same, display a prompt message of "test passed"; if they are different, display a prompt message of "test failed".

7. The device according to claim 6, characterized in that The acquisition module is further used for: Obtaining an input value corresponding to the target operation input; The generating module is used for: An operation code segment is generated based on the input value corresponding to the target operation, the identifier of the operation object and the target operation code template.

8. The device according to claim 7, characterized in that The generating module is used for: Acquire a first insertion position and a second insertion position corresponding to the pre-stored target operation code template; In the target operation code template, the identifier of the operation object is inserted into the first insertion position, and the input value corresponding to the target operation is inserted into the second insertion position to generate an operation code segment.

9. The device according to claim 6, characterized in that The generating module is used for: Obtaining a third insertion position and a fourth insertion position corresponding to the pre-stored result verification code template; In the target operation code template, the target parameter name is inserted into the third insertion position, and the reference parameter value is inserted into the fourth insertion position to generate a result verification code segment.

10. The device according to claim 6, characterized in that The operations include a click operation, a slide operation, and a data input operation.

11. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the operation performed by the method for generating test script code according to any one of claims 1 to 5.

12. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the operation performed by the method for generating test script code according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Interface test script generation method, system and device and storage medium

    CN111258900A