Test script generation method and device, equipment, storage medium and program product
By generating interface test script templates and conducting exploratory testing in multi-terminal interface automated testing, test script sets are automatically generated, solving the problems of large testing workload and coverage dependence on experience in existing technologies, achieving more efficient test coverage and reducing maintenance costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2022-06-27
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technologies for automated testing of multi-terminal interfaces suffer from problems such as large testing workload, coverage dependence on testers' experience, and large workload for script development and maintenance.
By recording the clicks on controls in the interface to be tested, a test script template is generated. Combined with strategy- and scenario-based exploratory testing, the control triggering order and input result set are automatically generated, a test script set is generated, and assertions are inserted into the script to verify the results.
It improved test coverage and efficiency, reduced the workload of testers in manually recording and writing scripts, and lowered maintenance costs.
Smart Images

Figure CN115292157B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, specifically to the field of automated testing technology, and more specifically to a test script generation method, apparatus, device, storage medium, and program product. Background Technology
[0002] With the development of the internet, customers now access computer services through a variety of channels and interfaces, leading to increasingly higher requirements for multi-terminal interface testing. Manual testing is labor-intensive, making automated multi-terminal interface testing more urgent. For example, the gaming industry needs to consider compatibility testing across different mobile operating systems, while PC users need to consider compatibility testing across different browsers. The banking industry, in addition to mobile banking and online banking channels, also needs to consider interface testing for counter services and self-service terminals.
[0003] Testing across multiple terminals typically involves manual testing. This begins with designing test cases based on business requirements, covering as many scenarios as possible. However, the same business function interface on different channels, such as mobile banking, online banking, bank counters, and self-service terminals, requires manual execution and verification for each channel. This is a significant workload, and test case design is prone to omissions. Furthermore, considering mobile banking in the banking industry, the mainstream mobile operating systems are Android and iOS, necessitating compatibility testing for both. Subtle differences between different mobile phone brands' operating systems also require compatibility testing for all test cases, exponentially increasing the workload. Therefore, the need for automated testing across multiple terminals is particularly urgent.
[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] In view of the above problems, this disclosure provides a method, apparatus, device, medium and program product for generating test scripts to improve the efficiency of multi-terminal interface testing.
[0006] According to a first aspect of this disclosure, a method for generating test scripts is provided, comprising:
[0007] Obtain the interface test script template for the interface to be tested, wherein the interface test script template is generated by recording the clicks of controls in the interface to be tested;
[0008] The interface test script template is subjected to strategy-based exploratory testing to determine the result set of control triggering order;
[0009] Scenario-based exploratory testing is performed on the interface test script template to determine the control input result set; and
[0010] The test script set for the interface to be tested is generated based on the result set of the control triggering order and the result set of the control input.
[0011] According to embodiments of this disclosure, the step of performing strategy-based exploratory testing on the interface test script template to determine the result set of control triggering order includes:
[0012] Obtain all control elements of the interface script template, including control variables and control constants;
[0013] The execution order of controls is determined based on a preset testing strategy and the control elements, and the control execution order includes a fixed execution order and a flexible execution order; and
[0014] The control triggering order result set is determined based on the fixed execution order and the flexible execution order, and the triggering order result set is a collection of multiple sequential result test scripts.
[0015] According to embodiments of this disclosure, determining the control triggering order result set based on the fixed execution order and the mobile execution order includes:
[0016] The control constants and control variables that determine the execution order of the machine are sorted using permutations and combinations to obtain all possible permutation and combination results; and
[0017] A control triggering order result set is generated based on the fixed execution order and the permutation and combination results.
[0018] According to embodiments of this disclosure, the step of performing scenario-based exploratory testing on the interface test script template to determine the control input result set includes:
[0019] Get all control variables of the interface script template;
[0020] The input set of the control variables is determined according to the equivalence class partitioning method based on the test scenario; and
[0021] Perform a Cartesian product operation on the input set of the control variable to determine the control input result set.
[0022] According to embodiments of this disclosure, generating the test script set for the interface to be tested based on the control triggering order result set and the control input result set includes:
[0023] The input data of the control input result set is sequentially traversed according to the trigger order result set of the control trigger order result set to generate the test script set of the interface to be tested.
[0024] According to embodiments of this disclosure, after generating the test script set for the interface to be tested, the method further includes:
[0025] Insert assertions into each test script for the interface to be tested; and
[0026] Output the assertion test results after executing the test script.
[0027] A second aspect of this disclosure provides a test script generation apparatus, comprising: an acquisition module for acquiring an interface test script template for a test interface, wherein the interface test script template is generated by recording clicks on controls in the test interface;
[0028] The first determining module is used to perform strategy-based exploratory testing on the interface test script template to determine the result set of control triggering order;
[0029] The second determining module is used to perform scenario-based exploratory testing on the interface test script template to determine the control input result set; and
[0030] The generation module is used to generate a test script set for the interface to be tested based on the result set of the control triggering order and the result set of the control input.
[0031] According to embodiments of this disclosure, the device further includes:
[0032] The assertion insertion module is used to insert assertions in each test script of the interface to be tested;
[0033] The output module is used to output the assertion test results after the test script is executed.
[0034] According to embodiments of this disclosure, the first determining module includes:
[0035] The first acquisition submodule is used to acquire all control elements of the interface script template, the control elements including control variables and control constants;
[0036] The first determining submodule is used to determine the execution order of controls based on a preset testing strategy and the control elements, wherein the control execution order includes a fixed execution order and a flexible execution order; and
[0037] The second determining submodule is used to determine the control triggering order result set based on the fixed execution order and the flexible execution order, wherein the triggering order result set is a collection of multiple sequential result test scripts.
[0038] According to embodiments of this disclosure, the second determining submodule includes:
[0039] The sorting unit is used to sort control constants and control variables that affect the execution order of the machine using permutations and combinations to obtain all permutation and combination results; and
[0040] The generation unit is used to generate a control triggering order result set based on the fixed execution order and the permutation and combination results.
[0041] According to embodiments of this disclosure, the second determining module includes:
[0042] The second acquisition submodule is used to acquire all control variables of the interface script template;
[0043] The third determining submodule is used to determine the input set of the control variables according to the equivalence class partitioning method based on the test scenario; and
[0044] The fourth determination submodule is used to perform a Cartesian product operation on the input set of the control variable to determine the control input result set.
[0045] According to embodiments of this disclosure, the generation module includes:
[0046] The traversal submodule is used to traverse the input data of the control input result set according to the trigger order result set of the control trigger order result set in order to generate the test script set of the interface to be tested.
[0047] A third aspect of this disclosure provides an electronic device comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the test script generation method described above.
[0048] A fourth aspect of this disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the above-described test script generation method.
[0049] The fifth aspect of this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described test script generation method.
[0050] The test script generation method provided by the embodiments of this disclosure involves recording the clicking and input of controls on the interface to be tested to obtain an interface test script template. Using the interface test script template as input, strategy-based exploratory testing generates a control triggering order result set, and scenario-based exploratory testing generates a control input result set. Finally, using the control triggering order result set and the control input result set as input, a test script set is generated based on free exploratory testing. Compared with existing technologies, the test script generation method of the embodiments of this disclosure automatically generates test scripts, provides more comprehensive test coverage, reduces the workload of testers manually recording test scripts and writing test code, and improves testing efficiency. Attached Figure Description
[0051] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0052] Figure 1 The illustration schematically depicts application scenarios of the test script generation method, apparatus, device, medium, and program product according to embodiments of the present disclosure;
[0053] Figure 2 A flowchart illustrating a test script generation method according to an embodiment of the present disclosure is shown schematically.
[0054] Figure 3a One of the flowcharts illustrating a method for generating a control triggering sequence result set according to an embodiment of the present disclosure is shown schematically;
[0055] Figure 3b The flowchart illustrating the method for generating a result set of control triggering order according to an embodiment of the present disclosure is shown in the second part.
[0056] Figure 3c A schematic diagram illustrating the control triggering sequence according to an embodiment of the present disclosure is provided.
[0057] Figure 4a A flowchart illustrating a method for determining a set of control input results according to an embodiment of the present disclosure is shown schematically.
[0058] Figure 4b A schematic diagram illustrating various control input sets according to embodiments of the present disclosure is provided.
[0059] Figure 5a This is a flowchart of a method for generating a test script set for an interface to be tested according to an embodiment of this disclosure;
[0060] Figure 5b This is a schematic diagram illustrating the generation of a set of input results for all trigger sequences based on a free-form exploratory test according to an embodiment of this disclosure.
[0061] Figure 6 This is a flowchart of an assertion testing method provided according to an embodiment of the present disclosure;
[0062] Figure 7 A schematic diagram illustrating the structure of a test script generation apparatus according to an embodiment of the present disclosure is shown; and
[0063] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a test script generation method according to an embodiment of the present disclosure. Detailed Implementation
[0064] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0065] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0066] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0067] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0068] First, let's explain the terms that appear in this disclosure:
[0069] Exploratory testing can be considered a testing mindset. While it doesn't rely on numerous specific testing methods, techniques, or tools, it represents a testing mindset that all testers should master. Exploratory testing emphasizes the tester's initiative, abandoning complex test planning and test case design processes, and stressing the importance of promptly changing testing strategies when problems arise. It generally includes the following four types of exploratory testing: free-form exploratory testing, scenario-based exploratory testing, strategy-based exploratory testing, and feedback-based exploratory testing.
[0070] Machine learning: Machine learning is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, and many other disciplines. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structures to continuously improve their performance. It is the core of artificial intelligence and the fundamental way to endow computers with intelligence.
[0071] Exploratory Testing Model: The exploratory testing model in this paper is a test model built by trying to use machine learning methods and combining free-form exploratory testing, scenario-based exploratory testing, and policy-based exploratory testing.
[0072] Airtest: Airtest is a cross-platform, open-source UI automation testing framework based on image recognition principles, suitable for games and applications. It supports Windows, Android, and iOS systems.
[0073] In multi-terminal interface testing scenarios, differences in terminal brands and operating systems lead to variations in the interface of the same business function across different channels, such as mobile banking, online banking, bank counters, and self-service terminals in the banking industry. Testers need to manually execute and verify these cases on each channel, resulting in a significant workload. Furthermore, test case design is prone to omissions. Considering the banking industry's mobile banking, which currently uses both Android and iOS as mainstream operating systems, compatibility testing for both systems is necessary. Additionally, subtle differences exist between different mobile phone brands' operating systems, requiring compatibility testing for all cases, exponentially increasing the workload. Therefore, the need for automated testing across multiple terminals is particularly urgent.
[0074] Early terminal testing tools required identifying each terminal control, such as input fields, pop-ups, and buttons, and writing terminal test scripts through coding. This demanded high coding skills from testers and involved a significant amount of coding and script maintenance. Airtest, a cross-platform UI automation testing framework based on image recognition principles, provides an alternative solution for multi-terminal automated testing. Using this framework, testers can generate test scripts by manually recording tests of a specific terminal interface. After designing test cases based on business requirements, testers can manually record test script sets using the Airtest framework and apply these sets to terminal interfaces across various channels and systems, reducing the manual testing workload. Furthermore, if the terminal interface is modified, the previously recorded test script sets can be replayed, thus achieving automated testing of multiple terminal interfaces.
[0075] However, the following issues still exist within the Airtest testing framework:
[0076] 1. Test script coverage depends on the tester's experience in test case design. Automated testing using the Airtest testing framework or other terminal testing tools involves recording test scripts or writing test code based on pre-designed test cases. If the tester's design is incomplete, there will be no corresponding test script to cover the relevant scenarios. As the complexity of the test scenarios increases, achieving comprehensive test script coverage becomes increasingly difficult.
[0077] 2. Test script development is labor-intensive. Test scripts require testers to manually record or write test code one by one to form a test script set, which is a significant workload. Moreover, as the complexity of the test scenarios increases and the number of test cases grows, the workload of test script development will increase exponentially.
[0078] 3. The workload for maintaining test scripts is significant. If the interface functionality is modified, all test scripts affecting that modification need to be manually modified, involving either re-recording of test scripts or maintenance of the test code. This increases the cost for testers to maintain test scripts. The more complex the interface modification, the greater the workload for test script maintenance will be.
[0079] To address the aforementioned technical issues, embodiments of this disclosure provide a test script generation method, comprising: obtaining an interface test script template for a test interface, wherein the interface test script template is generated by recording clicks on controls in the test interface; performing strategy-based exploratory testing on the interface test script template to determine a control triggering order result set; performing scenario-based exploratory testing on the interface test script template to determine a control input result set; and generating a test script set for the test interface based on the control triggering order result set and the control input result set.
[0080] Figure 1 The illustration schematically depicts application scenarios of the test script generation method, apparatus, device, medium, and program product according to embodiments of the present disclosure.
[0081] like Figure 1 As shown, application scenario 100 according to this embodiment may include a multi-terminal interface testing scenario. Network 104 is used as a medium to provide a communication link between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links or fiber optic cables, etc.
[0082] Testers can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0083] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0084] Server 105 can be a test script generation server that performs exploratory testing on interface scripts recorded by testers to generate full test scripts. For example, in response to interface test recording scripts sent by testers using terminal devices 101, 102, and 103, the test script generation server can analyze and process the received interface test script templates, input the established exploratory test model, and automatically generate test scripts based on the Airtest test framework.
[0085] It should be noted that the test script generation method provided in this embodiment can generally be executed by server 105. Correspondingly, the test script generation apparatus provided in this embodiment can generally be located in server 105. The test script generation method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the test script generation apparatus provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.
[0086] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0087] It should be noted that the test script generation method and apparatus determined in the embodiments of this disclosure can be used in the field of automated testing in the financial field, and can also be used in any field other than the financial field. The application field of the test script generation method and apparatus determined in the embodiments of this disclosure is not limited.
[0088] The following will be based on Figure 1 The described scene, through Figures 2-6 The test script generation method of the present disclosure embodiments will be described in detail.
[0089] Figure 2 A flowchart illustrating a test script generation method according to an embodiment of this disclosure is shown schematically. Figure 2 As shown, the test script generation method of this embodiment includes operations S210 to S240. This method can be executed by a multi-terminal interface automated testing tool that automatically generates test scripts, or by a server or other computing device. In view of the existing and current challenges, this invention develops a multi-terminal interface automated testing tool that automatically generates test scripts based on the Airtest testing framework and utilizing an exploratory testing model. Users can use this tool to simulate the entire user interaction process of a business interface by establishing an exploratory testing model. Then, based on the business scenario and testing strategy, machine learning methods are used to automatically generate test script code based on the Airtest testing framework. The automatically generated test scripts have a uniform style, greatly reducing the workload of testers manually recording scripts or manually writing interface test code, and significantly improving the automation level of interface testing. The test script generation method provided in this embodiment specifically includes operations S210 to S230.
[0090] In operation S210, obtain the interface test script template of the interface to be tested.
[0091] According to embodiments of this disclosure, the interface test script template is generated by recording clicks to input controls in the interface to be tested.
[0092] In one example, the Airtest testing framework is used to record clicks or input of all controls on the interface to generate a basic template for interface testing. Airtest is cross-platform, supporting interface testing on multiple platforms including Windows, Android, and iOS. Furthermore, the framework supports script recording, reducing the workload of testers manually writing test code. Taking a bank counter transaction interface as an example, in this transaction, testers click or fill in all controls on the interface based on the input fields, such as entering specific information like name, ID type, and ID number. The specific content is not limited. The output of this step is a generated test script template. This prepares for subsequent machine learning, the application of exploratory testing models, and the generation of the final set of interface test scripts.
[0093] Testers record clicks on all controls on the interface under test, obtaining the control test code and adding comments to it to improve readability. Controls are extracted from the page test script template, defining control constants and variables. Control constants: For fixed input controls, such as `key event("{ENTER}")`, no variable is needed, nor is it required as a variable in the subsequent exploratory test model; these can remain unchanged. Control variables: For example, `text(trxDataMap.get("idCode"))` needs to be variableized. The input box name can be modified using a variable with business implications, such as naming the ID number as `idCode`. In the subsequent exploratory test model, this node will also be named: `control idCode` for machine learning modeling.
[0094] In this embodiment, an exploratory testing model is established using machine learning methods. It mainly uses three types of exploratory testing: policy-based exploratory testing, scenario-based exploratory testing, and freedom-based exploratory testing. These three types of methods are implemented in the model in sequence, taking the interface test script template generated in operation S210 as input, and processing the three types of exploratory testing methods in sequence, as detailed in operations S220 to S240.
[0095] In operation S220, a strategy-based exploratory test is performed on the interface test script template to determine the result set of control triggering order.
[0096] In one example, policy-based exploratory testing determines the triggering order of various UI controls and generates a control triggering order result set. Specifically, the UI test script template generated in operation S210 is used as input. Control constants and variables are extracted from the template. According to the testing strategy, except for control constants and variables with a fixed order, control constants and variables with a flexible order are sorted by permutation and combination. Each permutation and combination will form a control triggering order result. For the detailed generation process, please refer to [link to documentation]. Figure 3a Operations S221 to S223 will not be described in detail here.
[0097] In operation S230, scenario-based exploratory testing is performed on the interface test script template to determine the control input result set.
[0098] In one example, different test scenarios correspond to different control triggering orders, which may result in different test results. To achieve full coverage of interface testing, this embodiment of the disclosure uses scenario-based exploratory testing to formulate input equivalence classes for each interface control, generating an input result set for a specific triggering order. Using the interface test template generated in operation S210 as input, control variables are extracted from the template. Using the equivalence class partitioning method in testing theory, the input values of each control variable are enumerated, and finally, an input result set for a specific triggering order is generated. For the specific generation process, see [link to documentation]. Figure 4a Operations S231 to S233 shown will not be described again here.
[0099] In operation S240, a test script set for the interface to be tested is generated based on the control triggering order result set and the control input result set.
[0100] In one example, the control trigger order result set obtained from operation S220 and the control input result set obtained from operation S230 are used as inputs. A test script for the interface to be tested is generated by iterating through all input data in the input result set using a specific trigger order result from the control trigger order result set. The process of generating the test script set can be found in [link to relevant documentation]. Figure 5a The operation S241 shown will not be described again here.
[0101] The test script generation method provided by the embodiments of this disclosure involves recording the clicking and input of controls on the interface to be tested to obtain an interface test script template. Using the interface test script template as input, strategy-based exploratory testing generates a control triggering order result set, and scenario-based exploratory testing generates a control input result set. Finally, using the control triggering order result set and the control input result set as input, a test script set is generated based on free exploratory testing. Compared with existing technologies, the test script generation method of the embodiments of this disclosure automatically generates test scripts, provides more comprehensive test coverage, reduces the workload of testers manually recording test scripts and writing test code, and improves testing efficiency.
[0102] Figure 3a This schematically illustrates one of the flowcharts for a method of generating a control triggering sequence result set according to an embodiment of the present disclosure. Figure 3b This schematically illustrates a second flowchart of a method for generating a control triggering sequence result set according to an embodiment of the present disclosure. Figure 3c This diagram schematically illustrates the control triggering sequence according to an embodiment of the present disclosure. For example... Figure 3a As shown, operation S220 includes operations S221 to S223.
[0103] In operation S221, all control elements of the interface script template are obtained, including control variables and control constants.
[0104] In operation S222, the execution order of the controls is determined according to the preset test strategy and the control elements.
[0105] In operation S223, the control triggering order result set is determined according to the fixed execution order and the mobile execution order.
[0106] According to embodiments of this disclosure, the triggering sequence result set is a collection of multiple sequence result test scripts.
[0107] In one example, control constants and control variables are extracted from the template and defined as control A, control B... control N for modeling, such as... Figure 3c As shown, based on the testing strategy, two types of control sequences are defined: fixed sequence and flexible sequence. Fixed sequence: The execution order of these controls is fixed and they must be executed sequentially in a fixed order, such as... Figure 3c Controls A and B in the code must be executed before control B can be executed. Flexible execution order: Clients can execute these controls freely, and the order in which they are executed will have different impacts on the transaction's outcome, leading to variations in the interaction results. Figure 3c The {control C, ..., control F} in the code is a set of control sequences.
[0108] like Figure 3b As shown, operation S223 includes operations S2231 to S2232.
[0109] In operation S2231, the control constants and control variables of the motor execution order are sorted by permutation and combination to obtain all permutation and combination results.
[0110] In operation S2232, a control triggering order result set is generated based on the fixed execution order and the permutation and combination results.
[0111] In one example, the control constants and control variables that determine the execution order of the machine are sorted using permutations and combinations to obtain all possible results. If there are m controls in {control C, ..., control F}, the permutation calculation will produce... The result is a sequence. If there is another set of control sequences {control H, ..., control L} following this sequence, totaling n controls, the result will be calculated based on the permutation. The result set of the control trigger sequence will ultimately produce a sequence of results. A sequence of results is generated. Then, a control is added to these permutation and combination results to generate a fixed execution order, triggering a sequence result set. The result file will be named "Business Scenario-Sequence Number", such as: 51102-RMB-Person-Full Screen-1, using the sequence number to distinguish different sequence result test scripts.
[0112] Figure 4a A flowchart illustrating a method for determining a set of control input results according to an embodiment of the present disclosure is shown schematically. Figure 4b A schematic diagram illustrating various control input sets according to embodiments of the present disclosure is provided. Figure 4a As shown, operation S230 includes operations S231 to S233.
[0113] In operation S231, all control variables of the interface script template are obtained.
[0114] In operation S232, the input set of the control variable is determined according to the equivalence class partitioning method based on the test scenario.
[0115] In operation S233, a Cartesian product operation is performed on the input set of the control variable to determine the control input result set.
[0116] In one example, the interface test script template generated in operation S210 is used as input. The control variables in the template are extracted and defined as control A, control B... control N for modeling, such as... Figure 4bAs shown, the equivalence class partitioning method from testing theory is used to list the input sets of each control. For example, the input set of control A is {A1……Aw}, the input set of control B is {B1……Bx}, the input set of control C is {C1……Cy}, and the input set of control N is {N1……Nz}. For example, idCode:{110101100101101010,12345,0845638} means that the value of control idCode can be any one of 1101011001011010, 12345, or 0845638. Based on the cross-combination of values for each control, the Cartesian product operation is performed on the input set of each control to ultimately produce... The result set is as follows: (The input results from each control are listed below.)
[0117]
[0118] Figure 5a This is a flowchart of a method for generating a test script set for an interface to be tested according to an embodiment of this disclosure. Figure 5b This is a schematic diagram illustrating the generation of an input result set for all trigger sequences based on a free-form exploratory test according to an embodiment of this disclosure, as shown below. Figure 5a As shown, operation S240 includes operation S241.
[0119] In operation S241, the input data of the control input result set is traversed sequentially according to the trigger order result of the control trigger order result set to generate the test script set of the interface to be tested.
[0120] In one example, taking the result set of control trigger order output by operation S220 and the input result set of a certain trigger order output by operation S230 as input, after processing by a free-form exploratory testing model, the output is the UI test script result after full machine learning. For example... Figure 5b As shown, according to Figure 3c The exploratory test model, after processing, will output a set of triggering order results for controls A, B, ..., N, becoming... Figure 5b The columns in the array, totaling N= Each triggering sequence result, according to Figure 4b After processing, the exploratory test model will output the set of input results for a certain triggering order of control A, control B... control N, becoming... Figure 5b The number of rows is m = The input results of each control are then processed. Therefore, the final exploratory test model will output the results. Results of the UI test script.
[0121] After generating the test script set, test assertions can be inserted into the test scripts to better verify the test results, such as whether the test results are correct. Figure 6 This is a flowchart of an assertion testing method provided according to embodiments of this disclosure. Figure 6 As shown, it includes operation S310 and operation S320.
[0122] When operating S310, insert assertions in each test script of the interface to be tested.
[0123] When operating the S320, the assertion test results are output after the test script is executed.
[0124] In one example, test assertions are inserted into the test script, such as: `assert_exists`: asserts the image exists; `assert_not_exists`: asserts the image does not exist; `assert_equal`: asserts equality; `assert_not_equal`: asserts inequality, etc. Based on the output results, there are generally cases of successful and failed transactions. Failed transactions have different error messages for different reasons. The script calls the test report output interface, passing in a few necessary report parameters, and after the script finishes running, it can automatically generate an Airtest report as required. The report contains basic information about this test, such as: `Step` - the number of steps performed; `Time` - the transaction duration; `Log` - more detailed test logs can be downloaded. If a test assertion passes, it is displayed in the "Passed" header, indicating which step and which assertion passed.
[0125] Based on the above-described test script generation method, this disclosure also provides a test script generation apparatus. The following will be combined with... Figure 7 The system is described in detail.
[0126] Figure 7 A schematic block diagram of a test script generation apparatus according to an embodiment of the present disclosure is shown.
[0127] like Figure 7 As shown, the SMS problem event processing system 800 of this embodiment includes an acquisition module 810, a first determination module 820, a second determination module 830, and a generation module 840.
[0128] The acquisition module 810 is used to acquire the interface test script template of the interface to be tested, wherein the interface test script template is generated by recording the clicks and inputs of controls in the interface to be tested. In one embodiment, the acquisition module 810 can be used to perform the operation S210 described above, which will not be repeated here.
[0129] The first determining module 820 is used to perform strategy-based exploratory testing on the interface test script template to determine the result set of control triggering order. In one embodiment, the first determining module 820 can be used to execute the operation S220 described above, which will not be repeated here.
[0130] The second determining module 830 is used to perform scenario-based exploratory testing on the interface test script template to determine the control input result set. In one embodiment, the second determining module 830 can be used to execute the operation S230 described above, which will not be repeated here.
[0131] The generation module 840 is used to generate a test script set for the interface to be tested based on the control triggering order result set and the control input result set, wherein the target processing strategy is preset according to the business processing flow. In one embodiment, the processing strategy determination module 840 can be used to execute the operation S240 described above, which will not be repeated here.
[0132] According to embodiments of this disclosure, it further includes: an assertion insertion module 850 and an output module 860.
[0133] The assertion insertion module 850 is used to insert assertions in each test script of the interface to be tested. In one embodiment, the assertion insertion module 850 can be used to perform the operation S310 described above, which will not be repeated here.
[0134] The output module 860 is used to output the assertion test results after the test script is executed. In one embodiment, the output module 860 can be used to perform the operation S320 described above, which will not be repeated here.
[0135] According to embodiments of this disclosure, the first determining module 820 includes: a first acquiring submodule, a first determining submodule, and a second determining submodule.
[0136] The first acquisition submodule is used to acquire all control elements of the interface script template, including control variables and control constants. In one embodiment, the first acquisition submodule can be used to perform the operation S221 described above, which will not be repeated here.
[0137] The first determining submodule is used to determine the execution order of controls based on a preset testing strategy and the control elements. The execution order includes a fixed execution order and a flexible execution order. In one embodiment, the first determining submodule can be used to perform the operation S222 described above, which will not be repeated here.
[0138] The second determining submodule is used to determine the control triggering order result set based on the fixed execution order and the flexible execution order, wherein the triggering order result set is a collection of multiple sequential result test scripts. In one embodiment, the second determining submodule can be used to execute the operation S223 described above, which will not be repeated here.
[0139] According to embodiments of this disclosure, the second determining submodule includes a sorting unit and a generating unit.
[0140] The sorting unit is used to sort the control constants and control variables of the dynamic execution order by performing permutations and combinations to obtain all permutation and combination results. In one embodiment, the sorting unit can be used to perform the operation S2231 described above, which will not be repeated here.
[0141] The generation unit is used to generate a control triggering order result set based on the fixed execution order and the permutation and combination results. In one embodiment, the generation unit can be used to perform the operation S2232 described above, which will not be repeated here.
[0142] According to embodiments of this disclosure, the second determining module 830 includes: a second acquiring submodule, a third determining submodule, and a fourth determining submodule.
[0143] The second acquisition submodule is used to acquire all control variables of the interface script template. In one embodiment, the second acquisition submodule can be used to perform the operation S231 described above, which will not be repeated here.
[0144] The third determining submodule is used to determine the input set of the control variables according to the equivalence class partitioning method based on the test scenario. In one embodiment, the third determining submodule can be used to perform the operation S232 described above, which will not be repeated here.
[0145] The fourth determining submodule is used to perform a Cartesian product operation on the input set of the control variable to determine the control input result set. In one embodiment, the fourth determining submodule can be used to perform the operation S233 described above, which will not be repeated here.
[0146] According to embodiments of this disclosure, generation module 840 includes a traversal submodule.
[0147] The traversal submodule is used to sequentially traverse the input data of the control input result set according to the trigger order result set of the control trigger order result set, so as to generate the test script set of the interface to be tested. In one embodiment, the traversal submodule can be used to execute the operation S241 described above, which will not be repeated here.
[0148] According to embodiments of this disclosure, any plurality of modules among the acquisition module 810, the first determination module 820, the second determination module 830, and the generation module 840 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the acquisition module 810, the first determination module 820, the second determination module 830, and the generation module 840 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in any one of software, hardware, and firmware methods, or in a suitable combination of any of these methods. Alternatively, at least one of the acquisition module 810, the first determination module 820, the second determination module 830, and the generation module 840 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0149] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a test script generation method according to an embodiment of the present disclosure.
[0150] like Figure 8 As shown, an electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0151] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0152] According to embodiments of this disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0153] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the test script generation method according to the embodiments of this disclosure.
[0154] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 902 and / or RAM 903 and / or one or more memories other than ROM 902 and RAM 903 described above.
[0155] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the test script generation method provided in the embodiments of this disclosure.
[0156] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0157] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0158] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0159] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on a user's computing device, partially on a user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0160] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0161] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0162] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A method for generating test scripts, characterized in that, include: Obtain the interface test script template for the interface to be tested, wherein the interface test script template is generated by recording the clicks of controls in the interface to be tested; The interface test script template is subjected to strategy-based exploratory testing to determine the result set of control triggering order; Scenario-based exploratory testing is performed on the interface test script template to determine the control input result set; as well as The input data of the control input result set is traversed sequentially according to the trigger order result set of the control trigger order result set to generate the test script set of the interface to be tested; The strategy-based exploratory testing includes determining the control execution order based on the control elements of the interface test script template and the preset test strategy, and determining the control triggering order result set based on the control execution order. The step of performing scenario-based exploratory testing on the interface test script template to determine the control input result set includes: Retrieve all control variables of the interface test script template; The input set of the control variables is determined according to the equivalence class partitioning method based on the test scenario; and Perform a Cartesian product operation on the input set of the control variable to determine the control input result set; The strategy-based exploratory testing of the interface test script template to determine the result set of control triggering order includes: Obtain all control elements of the interface test script template, including control variables and control constants; The execution order of controls is determined based on a preset test strategy and the control elements. The execution order of controls includes a fixed execution order and a flexible execution order. The control constants and control variables that determine the execution order of the machine are sorted by permutation and combination to obtain all permutation and combination results; A control triggering order result set is generated based on the fixed execution order and the permutation and combination results; the triggering order result set is a collection of multiple sequential result test scripts.
2. The method according to claim 1, characterized in that, After generating the test script set for the interface to be tested, the process also includes: Insert assertions into each test script for the interface to be tested; and Output the assertion test results after executing the test script.
3. A test script generation device, comprising: The acquisition module is used to acquire the interface test script template of the interface to be tested, wherein the interface test script template is generated by recording the clicks of controls in the interface to be tested; The first determining module is used to perform strategy-based exploratory testing on the interface test script template to determine the result set of control triggering order; The second determining module is used to perform scenario-based exploratory testing on the interface test script template to determine the control input result set; as well as The generation module is used to sequentially traverse the input data of the control input result set according to the trigger order result set of the control trigger order result set, so as to generate the test script set of the interface to be tested; The first determining module is further configured to determine the control execution order based on the control elements of the interface test script template and the preset test strategy, and determine the control triggering order result set based on the control execution order; obtain all control elements of the interface test script template, the control elements including control variables and control constants; determine the control execution order based on the preset test strategy and the control elements, the control execution order including a fixed execution order and a flexible execution order; sort the control constants and control variables of the flexible execution order by permutation and combination to obtain all permutation and combination results; generate a control triggering order result set based on the fixed execution order and the permutation and combination results; the triggering order result set is a collection of multiple sequential result test scripts; The second determining module is also used to obtain all control variables of the interface test script template; The input set of the control variable is determined according to the equivalence class partitioning method based on the test scenario; and the Cartesian product operation is performed on the input set of the control variable to determine the control input result set.
4. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 2.
5. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 2.
6. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 2.