CN115292157A - Test script generation method, device, equipment, storage medium and program product - Google Patents

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

Info

Publication number
CN115292157A
CN115292157A CN202210744949.7A CN202210744949A CN115292157A CN 115292157 A CN115292157 A CN 115292157A CN 202210744949 A CN202210744949 A CN 202210744949A CN 115292157 A CN115292157 A CN 115292157A
Authority
CN
China
Prior art keywords
control
interface
test
test script
result set
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210744949.7A
Other languages
Chinese (zh)
Inventor
梁晓珺
朱乐和
罗秉安
连煜伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210744949.7A priority Critical patent/CN115292157A/en
Publication of CN115292157A publication Critical patent/CN115292157A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Landscapes

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

Abstract

The disclosure provides a test script generation method, which can be applied to the technical field of finance. The method comprises the following steps: acquiring an interface test script template of an interface to be tested, wherein the interface test script template is generated by recording and clicking a control which is input into the interface to be tested; performing strategy-based exploratory testing on the interface test script template to determine a control trigger sequence result set; performing scene-based exploratory test on the interface test script template to determine a control input result set; and generating a test script set of the interface to be tested according to the control triggering sequence result set and the control input result set. The disclosure also provides a test script generating apparatus, a device, a storage medium and a program product.

Description

Test script generation method, device, equipment, storage medium and program product
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to the field of automated testing technologies, and in particular, to a test script generation method, apparatus, device, storage medium, and program product.
Background
With the development of the internet, the channel interfaces of the client accessing the computer service are various, the requirement on the multi-terminal interface test is higher and higher, the manual test workload is large, and the requirement on the multi-terminal interface automatic test is more urgent. For example: in the game industry, compatibility tests of different mobile phone systems of a mobile phone end need to be considered, and compatibility tests of different browsers need to be considered at a PC (personal computer) end; in the banking industry, interface tests such as counter and self-service terminal need to be considered besides mobile banking and internet banking channels.
For the test of multiple terminals, generally, the test is performed manually, and first, a test case is designed according to a service demand scenario to cover as many service scenarios as possible. However, the same business function interface is in different channels, such as mobile banking, internet banking, counter, self-service terminal, etc. in the banking industry, the cases need to be manually executed and verified in each channel, the test workload is large, and the test case omission condition is easily generated during the design of the test case. Further, for example, in a mobile phone bank in the banking industry, the current mainstream mobile phone systems include an Android system and an ios system, compatibility tests need to be performed on the Android system and the ios system, meanwhile, mobile phone systems of different mobile phone brands also have slight differences, compatibility tests need to be performed on all cases, and the test workload is increased in a geometric level. Therefore, the requirement of automatic test of multiple terminals is particularly urgent.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a test script generation method, apparatus, device, medium, and program product that improve multi-terminal interface test efficiency.
According to a first aspect of the present disclosure, there is provided a test script generation method, including:
acquiring an interface test script template of an interface to be tested, wherein the interface test script template is generated by recording and clicking a control which is input into the interface to be tested;
performing strategy-based exploratory testing on the interface testing script template to determine a control triggering sequence result set;
performing scene-based exploratory test on the interface test script template to determine a control input result set; and
and generating a test script set of the interface to be tested according to the control triggering sequence result set and the control input result set.
According to an embodiment of the present disclosure, performing a policy-based exploratory test on the interface test script template to determine a control trigger order result set includes:
acquiring all control elements of the interface script template, wherein the control elements comprise control variables and control constants;
determining a control execution sequence according to a preset test strategy and the control elements, wherein the control execution sequence comprises a fixed execution sequence and a maneuvering execution sequence; and
and determining a control trigger sequence result set according to the fixed execution sequence and the maneuvering execution sequence, wherein the trigger sequence result set is a set of a plurality of sequence result test scripts.
According to an embodiment of the present disclosure, determining a control trigger order result set according to the fixed execution order and the maneuver execution order includes:
the control constants and the control variables of the maneuvering execution sequence are sequenced in a permutation and combination mode to obtain all permutation and combination results; and
and generating a control trigger sequence result set according to the fixed execution sequence and the permutation and combination result.
According to an embodiment of the present disclosure, the performing a scene-based exploratory test on the interface test script template to determine a control input result set includes:
acquiring all control variables of the interface script template;
determining an input set of the control variables according to a test scene and an equivalence class dividing method; and
and carrying out Cartesian product operation on the input set of the control variables to determine a control input result set.
According to an embodiment of the present disclosure, the generating a test script set of the interface to be tested according to the control triggering order result set and the control input result set includes:
and traversing the input data of the control input result set according to the triggering sequence result of the control triggering sequence result set in sequence to generate a test script set of the interface to be tested.
According to the embodiment of the present disclosure, after the test script set of the interface to be tested is generated, the method further includes:
inserting an assertion into each test script of the interface to be tested; and
and outputting an assertion test result after the test script is executed.
A second aspect of the present disclosure provides a test script generating apparatus, including: the acquisition module is used for acquiring an interface test script template of the interface to be tested, wherein the interface test script template is generated by recording and clicking a control which is input into the interface to be tested;
the first determining module is used for carrying out strategy-based exploratory testing on the interface testing script template so as to determine a control triggering sequence result set;
the second determination module is used for carrying out scene-based exploratory test on the interface test script template so as to determine a control input result set; and
and the generating module is used for generating a test script set of the interface to be tested according to the control triggering sequence result set and the control input result set.
According to an embodiment of the present disclosure, the apparatus further comprises:
the assertion insertion module is used for inserting an assertion into each test script of the interface to be tested;
and the output module is used for outputting the assertion test result after the test script is executed.
According to an embodiment of the present disclosure, the first determining module includes:
the first obtaining sub-module is used for obtaining all control elements of the interface script template, wherein the control elements comprise control variables and control constants;
the first determining sub-module is used for determining a control execution sequence according to a preset test strategy and the control elements, and the control execution sequence comprises a fixed execution sequence and a maneuvering execution sequence; and
and the second determining submodule is used for determining a control triggering sequence result set according to the fixed execution sequence and the maneuvering execution sequence, and the triggering sequence result set is a set of a plurality of sequence result test scripts.
According to an embodiment of the present disclosure, the second determination submodule includes:
the sequencing unit is used for sequencing the control constants and the control variables of the maneuvering execution sequence in a permutation and combination mode to obtain all permutation and combination results; and
and the generating unit is used for generating a control triggering sequence result set according to the fixed execution sequence and the permutation and combination result.
According to an embodiment of the present disclosure, the second determining module includes:
the second obtaining sub-module is used for obtaining all control variables of the interface script template;
the third determining submodule is used for determining the input set of the control variable according to the test scene and an equivalence class dividing method; and
and the fourth determining submodule is used for carrying out Cartesian product operation on the input set of the control variables to determine a control input result set.
According to an embodiment of the disclosure, the generating module includes:
and the traversing submodule is used for traversing the input data of the control input result set according to the trigger sequence result of the control trigger sequence result set in sequence so as to generate a test script set of the interface to be tested.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the test script generation method described above.
The fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the above test script generation method.
A fifth aspect of the present disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the test script generation method described above.
According to the test script generating method provided by the embodiment of the disclosure, an interface test script template of an interface to be tested is obtained by recording, clicking and inputting a control of the interface to be tested, the interface test script template of the interface to be tested is used as input, an exploratory test based on a strategy is carried out to generate a control trigger sequence result set, and an exploratory test based on a scene is carried out to generate a control input result set; and taking the control triggering sequence result set and the control input result set as input, and generating a test script set based on free exploratory test. Compared with the prior art, the test script generation method disclosed by the embodiment of the disclosure automatically generates the test script, so that the test coverage is more comprehensive, the workload of manually recording the test script and compiling the test code by a tester is reduced, and the test efficiency is improved.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an application scenario diagram of a test script generation method, apparatus, device, medium and program product according to an embodiment of the disclosure;
FIG. 2 schematically illustrates a flow chart of a test script generation method according to an embodiment of the present disclosure;
FIG. 3a schematically illustrates one of the flowcharts of a method for generating a control trigger order result set according to an embodiment of the present disclosure;
FIG. 3b schematically illustrates a second flowchart of a method for generating a control-triggered sequential result set according to an embodiment of the present disclosure;
FIG. 3c is a schematic diagram that schematically illustrates a control activation sequence, in accordance with an embodiment of the present disclosure;
FIG. 4a schematically illustrates a flow chart of a method of determining a control input result set according to an embodiment of the present disclosure;
FIG. 4b schematically illustrates a diagram of control input sets, according to an embodiment of the present disclosure;
FIG. 5a is a flowchart of a method for generating a test script set of an interface to be tested according to an embodiment of the present disclosure;
FIG. 5b is a schematic diagram of an input result set for generating an overall trigger sequence based on a free-based heuristic test provided in accordance with an embodiment of the present disclosure;
FIG. 6 is a flow chart of a predicate testing method provided in accordance with an embodiment of the present disclosure;
FIG. 7 is a block diagram schematically illustrating a structure of a test script generating apparatus according to an embodiment of the present disclosure; and
FIG. 8 schematically illustrates a block diagram of an electronic device suitable for implementing a test script generation method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs, unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B, and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B, and C" would include but not be limited to systems that have A alone, B alone, C alone, A and B together, A and C together, B and C together, and/or A, B, and C together, etc.).
The terms appearing in the present disclosure are explained first:
exploratory property test: exploratory testing can be said to be a test thinking technique. It does not have many practical test methods, techniques and tools, but is a way of testing thinking that all testers should master. The exploratory emphasis is on the subjective initiative of testers, the complicated test plan and test case design process are abandoned, and the emphasis is on timely changing the test strategy when problems occur. The following 4 types of exploratory tests are generally included: a free-form heuristic test, a scenario-based heuristic test, a strategy-based heuristic test, and a feedback-based heuristic test.
Machine learning: machine learning is a multi-field cross subject and relates to a plurality of subjects such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and the like. The special research on how a computer simulates or realizes the learning behavior of human beings so as to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve the performance of the computer. It is the core of artificial intelligence and is the fundamental way to make computer have intelligence.
Exploratory test model: exploratory test models herein are test models that are created in an attempt to use machine learning, in conjunction with freestyle exploratory testing, scenario-based exploratory testing, and strategy-based exploratory testing.
Airtest: airtest is a cross-platform open-source UI automation testing framework based on the image recognition principle, and is suitable for games and application programs. And Windows, android and ios systems are supported.
In a multi-terminal interface test scene, due to differences of different terminal brands and operating systems, the same service function interface is different in different channels, such as mobile banking, internet banking, counter and self-service terminal in banking industry. The method is characterized in that a tester needs to manually execute and verify cases in each channel, the test workload is large, and the test case omission condition is easily generated during the design of the test cases. The need for automated testing of multiple terminals is particularly acute.
Early terminal testing tools required the following for each terminal control, such as: the input box, the popup box, the button and the like are marked, and the terminal test script is compiled in a coding mode, so that the requirement on the coding skill of a tester is high, the coding workload is high, and the code maintenance workload of the test script is high. The cross-platform UI automatic test framework based on the image recognition principle provides another solution for the automatic test of multiple terminals. By using the framework, a tester can generate a test script by recording a mode of manually testing a certain terminal interface. Therefore, after testing personnel design testing cases according to business requirement scenes, airtest testing frameworks are used for manually recording testing script sets, and the testing script sets are applied to terminal interfaces of systems of all channels, so that the manual testing workload of the testing personnel is reduced. And under the condition that the terminal interface is modified, the original recorded test script set can be played back, so that the automatic test of the multi-terminal interface is realized.
However, the following problems still exist under the Airtest framework:
1. test script coverage depends on the test case design experience of the tester. The Airtest framework or other terminal test tools are used for realizing automatic tests, and test scripts are recorded or test codes are written according to established test cases designed by testers. And if the design of the tester is omitted, no corresponding test script covers the corresponding scene. As the complexity of the test scenario increases, the greater the difficulty of full coverage of the test script.
2. The test script compiling workload is large. The test scripts need to be manually recorded one by one or manually compiled one by a tester, so that a test script set is formed, and the workload is large. And with the increase of the complexity of the test scene, the larger the number of the test cases is, the more the compiling workload of the test script is multiplied.
3. The test script maintenance workload is large. If the interface function is modified, all test scripts related to the modified point need to be modified manually, the test scripts are recorded again or the test codes are maintained, and the cost for maintaining the test scripts by testers is high. The maintenance workload of the test script is multiplied if the interface modification is more complicated.
Based on the above technical problem, an embodiment of the present disclosure provides a test script generation method, including: acquiring an interface test script template of an interface to be tested, wherein the interface test script template is generated by recording and clicking a control which is input into the interface to be tested; performing strategy-based exploratory testing on the interface test script template to determine a control trigger sequence result set; performing scene-based exploratory test on the interface test script template to determine a control input result set; and generating a test script set of the interface to be tested according to the control triggering sequence result set and the control input result set.
Fig. 1 schematically illustrates an application scenario diagram of a test script generation method, apparatus, device, medium, and program product according to embodiments of the present disclosure.
As shown in fig. 1, the application scenario 100 according to this embodiment may include a multi-terminal interface test scenario. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The test person may use the terminal devices 101, 102, 103 to interact with the server 105 over the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a test script generation server, and performs exploratory test on an interface script recorded by a tester to generate a full amount of test scripts, for example, in response to an interface test recording script sent by the tester by using the terminal devices 101, 102, and 103, the test script generation server may analyze and process a received interface test script template, input an established exploratory test model, and automatically generate a test script based on an Airtest framework.
It should be noted that the test script generation method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the test script generating apparatus provided by the embodiment of the present disclosure may be generally disposed in the server 105. The test script generation method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the test script generating apparatus provided in the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
It should be noted that the test script generation method and apparatus determined in the embodiments of the present disclosure may be applied to the automated testing field in the financial field, and may also be applied to any field other than the financial field.
The test script generation method according to the embodiment of the present disclosure will be described in detail below with reference to fig. 2 to 6 based on the scenario described in fig. 1.
FIG. 2 schematically shows a flow chart of a test script generation method according to an embodiment of the present disclosure. As shown in fig. 2, the test script generating method of this embodiment includes operations S210 to S240, and the method may be executed by a multi-terminal interface automation test tool that automatically generates the test script, or may be executed by a server or other computing device. In view of the current and redemption dilemmas, the invention develops a multi-terminal interface automated testing tool for automatically generating a testing script by utilizing an exploratory testing model on the basis of Airtest framework. A user can use the tool to simulate the user interaction process of the whole service interface by establishing an exploratory test model, and then automatically generate test script codes based on an Airtest test framework by using a machine learning method according to a service scene and a test strategy, the automatically generated test script has uniform style, the workload of manually recording scripts or manually writing interface test codes for testers is greatly reduced, and the automation degree of interface test is greatly improved. The test script generation method provided by the embodiment of the present disclosure specifically includes operation S210 to operation S230.
In operation S210, an interface test script template of an interface to be tested is obtained.
According to the embodiment of the disclosure, the interface test script template is generated by recording and clicking a control recorded in the interface to be tested.
In one example, an Airtest frame is used, all controls of an interface are clicked or recorded in a recording mode to generate an interface test basic template, and the Airtest frame has the cross-platform characteristic and can support multi-platform interface tests of Windows, android, ios systems and the like. And the test framework supports the function of recording scripts, so that the workload of test personnel for manually compiling test codes can be reduced. Taking a bank counter transaction interface as an example, in the transaction, a tester clicks or fills in all controls of the interface according to an input field of the interface, such as filling in specific information of names, certificate types, certificate numbers and the like, the specific content is not limited, and the output of the step is to generate a test script template. And applying the exploratory test model and then generating a final interface test script set for later machine learning.
And recording and clicking all controls of the interface to be tested by testers to obtain control test codes, and adding annotations to the control test codes to improve code readability. And extracting the control in the page test script template, and defining the control constant and the control variable. Control constants: for fixed input controls, such as: the key event ("{ ENTER }") is not required to be quantized, nor is it required to be a variable of a later exploratory test model, and can remain without editing. Control variables: such as: text ("idCode"), which requires quantization of variables, the name of the input box may be modified with variable names contained in the service, such as: the certificate number is named idCode. In the exploratory test model that follows, this node will also be named: and controlling the idCode to perform machine learning modeling.
In this embodiment, the exploratory test model is established by using a machine learning method, and three types of exploratory tests are mainly used: the three types of methods are sequentially implemented in the model, and the three types of exploratory tests are sequentially processed with the interface test script template generated in operation S210 as input, as detailed in operation S220 to operation S240.
In operation S220, an exploratory test based on a policy is performed on the interface test script template to determine a control trigger order result set.
In one example, a policy-based exploratory test formulates a trigger sequence of each interface control to generate a control trigger sequence result set, specifically, an interface test script template generated in operation S210 is used as an input, a control constant and a control variable in the template are extracted, the control constant and the control variable in the maneuver sequence are sorted in a permutation and combination manner according to the test policy except for the control constant and the control variable in the fixed sequence, and each permutation and combination manner forms a control trigger sequence result. For a specific generation process, refer to operations S221 to S223 described in fig. 3a, which are not described herein again.
In operation S230, a scenario-based exploratory test is performed on the interface test script template to determine a control input result set.
In one example, different test scenes correspond to different control trigger sequences, different test results may be obtained, and in order to implement full coverage of interface testing, the embodiment of the present disclosure formulates an input equivalence class of each interface control based on an exploratory test of a scene, and generates an input result set of a certain trigger sequence. Taking the interface test template generated in operation S210 as an input, extracting control variables in the template, enumerating the input value of each control variable by using an equivalence class division method in a test theory, and finally generating an input result set in a certain trigger sequence, where a specific generation process refers to operations S231 to S233 shown in fig. 4a, and details are not repeated here.
In operation S240, a test script set of the interface to be tested is generated according to the control trigger sequence result set and the control input result set.
In an example, the control trigger order result set obtained in operation S220 and the control input result set obtained in operation S230 are used as inputs, and a certain trigger order result in the control trigger order result set traverses all input data in the input result set to generate a test script for the interface to be tested, where a generating process of the test script set may refer to operation S241 shown in fig. 5a, and is not described herein again.
According to the test script generating method provided by the embodiment of the disclosure, an interface test script template of an interface to be tested is obtained by recording, clicking and inputting a control of the interface to be tested, the interface test script template of the interface to be tested is used as input, an exploratory test based on a strategy is carried out to generate a control trigger sequence result set, and an exploratory test based on a scene is carried out to generate a control input result set; and taking the control triggering sequence result set and the control input result set as input, and generating a test script set based on free exploratory test. Compared with the prior art, the test script generation method disclosed by the embodiment of the disclosure automatically generates the test script, so that the test coverage is more comprehensive, the workload of manually recording the test script and compiling the test code by a tester is reduced, and the test efficiency is improved.
Fig. 3a schematically shows one of flowcharts of a method for generating a result set of a control trigger order according to an embodiment of the present disclosure, fig. 3b schematically shows another flowchart of a method for generating a result set of a control trigger order according to an embodiment of the present disclosure, and fig. 3c schematically shows a schematic diagram of a control trigger order according to an embodiment of the present disclosure. As shown in FIG. 3a, operation S220 includes operations S221 through S223
In operation S221, all control elements of the interface script template are obtained, where the control elements include control variables and control constants.
In operation S222, a control execution sequence is determined according to a preset test strategy and the control element.
In operation S223, a control trigger order result set is determined according to the fixed execution order and the maneuver execution order.
According to an embodiment of the present disclosure, the trigger sequence result set is a set of a plurality of sequence result test scripts.
In one example, control constants and control variables in a template are extracted and defined as control A, control B \8230, control N is modeled, and as shown in FIG. 3c, two types of control sequences are defined according to a test strategy: a fixed sequence and a motorized sequence. Fixing sequence: the execution sequence of such controls is fixed, and the controls must be executed in sequence according to the fixed sequence, for example, the control a and the control B in fig. 3c, and the control B cannot be executed until the control a is executed. A maneuvering sequence: such controls can be executed by clients at will, and the execution result of the transaction will be affected differently according to the execution sequence of the clients, so that the interaction result will be different, for example, { controls C, \ 8230; \8230;, controls F } in fig. 3C is a set of maneuvering sequential controls.
As shown in fig. 3b, operations S2231 to S2232 are included in operation S223.
In operation S2231, the control constants and control variables of the maneuver execution sequence are sorted in a permutation and combination manner to obtain all permutation and combination results.
In operation S2232, a control trigger order result set is generated according to the fixed execution order and the permutation and combination result.
In one example, the control constants and control variables of the maneuver execution sequence are ordered in a permutation and combination manner to obtain all permutation and combination results, and if the { control C, \8230;, control F } has m controls in total, according to the permutation and calculation, the permutation and calculation result will generate
Figure RE-RE-GDA0003801785900000131
And (4) sequencing the results. If another group of maneuvering sequence controls (controls H, 8230; controls L) are n controls in total after the sequence, the calculation based on the arrangement will result in
Figure RE-RE-GDA0003801785900000132
And (4) sequencing the results. Then generating a control trigger order result set will eventually yield
Figure RE-RE-GDA0003801785900000133
And (6) sequencing the results. And then adding a fixed execution sequence into the permutation and combination results to generate a control trigger sequence result set. The result file will be named "business scenario-sequence number", as: 51102 Renminbi-I-FULL-1, using serial numbers to distinguish different sequence result test scripts.
Fig. 4a schematically shows a flowchart of a method for determining a control input result set according to an embodiment of the present disclosure, and fig. 4b schematically shows a schematic diagram of each control input set according to an embodiment of the present disclosure. As shown in fig. 4a, the operation S230 includes operations S231 to S233.
In operation S231, all control variables of the interface script template are acquired.
In operation S232, an input set of the control variable is determined according to the test scenario by the equivalence class division method.
In operation S233, a cartesian product operation is performed on the input set of control variables to determine a control input result set.
In one example, an interface test script template generated in operation S210 is used as an input, a control variable in the template is extracted and defined as a control a and a control B \8230, a control N is modeled, and as shown in fig. 4B, an input set of each control is enumerated by using an equivalence class division method in a test theory, such as: the input set of the control A is { A1 \8230; \8230, aw }, the input set of the control B is { B1 \8230; \8230, bx }, the input set of the control C is { C1 \8230; \8230, cy } \8230; \8230, the input set of the control N is { N1 \8230; \8230, nz }, for example, idCode: {110108198607224413, 12345, 0845638}, which indicates that the value of the idCode of the control can be: 110108198607224413, 12345, 0845638. According to the cross combination of each control value, carrying out Cartesian product operation on the input set of each control to finally generate w.x.y.z control input results, wherein the result set is as follows:
{A 1 …A w }×{B 1 …B x }×{C 1 …C y }×…×{N 1 …N n }
fig. 5a is a flowchart of a method for generating a test script set of an interface to be tested according to an embodiment of the present disclosure. Fig. 5b is a schematic diagram of generating an input result set of an overall trigger sequence based on a free-form heuristic test according to an embodiment of the present disclosure, and as shown in fig. 5a, operation S240 includes operation S241.
In operation S241, traversing the input data of the control input result set according to the trigger sequence result of the control trigger sequence result set in sequence to generate a test script set of the interface to be tested.
In one example, the result set of control trigger orders output in operation S220 and the input of a trigger order output in operation S230And the result set is input, and the interface test script results after the full-scale machine learning are output after the freely-based exploratory test model combination processing. As shown in FIG. 5B, the triggering sequence result set of control A, control B \8230 \ 8230and control N will be output after the exploratory test model of FIG. 3c is processed, and become the column and common row in FIG. 5B
Figure RE-RE-GDA0003801785900000141
Figure RE-RE-GDA0003801785900000142
After the triggering sequence results are processed according to the exploratory test model of fig. 4B, the input result set of a certain triggering sequence of the control a, the control B \8230 \ 8230and the control N becomes the row of fig. 5B, and m = w · x · y · · z control input results are totally output. Therefore, the output is obtained after the final exploratory test model processing
Figure RE-RE-GDA0003801785900000143
And testing the script result by the interface.
After the test script set is generated, a test assertion may be inserted into the test script in order to better verify the test result, e.g., whether the test result is correct. FIG. 6 is a flowchart of an assertion testing method provided in accordance with an embodiment of the present disclosure. As shown in fig. 6, operations S310 and S320 are included.
In operation S310, an assertion is inserted in each test script of an interface to be tested.
In operation S320, an assertion test result is output after the test script is executed.
In one example, a test assertion is inserted in a test script, such as: assert _ exists: assert picture present, assert _ not _ exists: assert picture not present, assert _ equal: assert equality, assert _ not _ equal: the assertions are unequal, and so on. And classifying according to output results, wherein the transaction success and the transaction failure generally exist, the transaction failure has errors of different reasons, an output test report interface is called in the script, and a plurality of necessary report parameters are transmitted, so that an Airtest report can be automatically generated according to requirements after the script runs. The report includes basic information of the test, such as: step-the operation Step performed, time-the transaction duration performed, log-more detailed test logs can be downloaded. If the test assertion passes, the display is shown on the title of the Passed and indicates which assertion Passed at which step.
Based on the test script generation method, the disclosure also provides a test script generation device. The system will be described in detail below in conjunction with fig. 7.
Fig. 7 schematically shows a block diagram of a test script generation apparatus according to an embodiment of the present disclosure.
As shown in fig. 7, the system 800 for processing a short message question event list of this embodiment includes an obtaining module 810, a first determining module 820, a second determining module 830, and a generating module 840.
The obtaining module 810 is configured to obtain an interface test script template of an interface to be tested, where the interface test script template is generated by recording and clicking a control recorded in the interface to be tested. In an embodiment, the obtaining module 810 may be configured to perform the operation S210 described above, which is not described herein again.
The first determination module 820 is used for performing policy-based exploratory testing on the interface test script template to determine a control trigger order result set. In an embodiment, the first determining module 820 may be configured to perform the operation S220 described above, and is not described herein again.
The second determining module 830 is configured to perform a scenario-based exploratory test on the interface test script template to determine a control input result set. In an embodiment, the second determining module 830 may be configured to perform the operation S230 described above, and is not described herein again.
The generating module 840 is configured to generate a test script set of the interface to be tested according to the control triggering sequence result set and the control input result set, where the target processing policy is preset according to a business processing flow. In an embodiment, the processing policy determining module 840 may be configured to perform the operation S240 described above, which is not described herein again.
According to an embodiment of the present disclosure, further comprising: an assertion insertion module 850 and an output module 860.
Assertion insertion module 850 is used to insert an assertion in each test script of the interface to be tested. In an embodiment, the assertion insertion module 850 may be configured to perform the operation S310 described above, which is not described herein again.
The output module 860 is used for outputting the assertion test result after the test script is executed. In an embodiment, the output module 860 may be configured to perform the operation S320 described above, which is not described herein again.
According to an embodiment of the present disclosure, the first determining module 820 includes: the device comprises a first obtaining submodule, a first determining submodule and a second determining submodule.
The first obtaining sub-module is used for obtaining all control elements of the interface script template, wherein the control elements comprise control variables and control constants. In an embodiment, the first obtaining submodule may be configured to perform the operation S221 described above, and details are not described herein again.
The first determining sub-module is used for determining a control execution sequence according to a preset test strategy and the control elements, and the control execution sequence comprises a fixed execution sequence and a maneuvering execution sequence. In an embodiment, the first determining submodule may be configured to perform operation S222 described above, and is not described herein again.
And the second determining submodule is used for determining a control triggering sequence result set according to the fixed execution sequence and the maneuvering execution sequence, and the triggering sequence result set is a set of a plurality of sequence result test scripts. In an embodiment, the second determining submodule may be configured to perform operation S223 described above, and is not described herein again.
According to an embodiment of the present disclosure, the second determination submodule includes: the device comprises a sorting unit and a generating unit.
The sequencing unit is used for sequencing the control constants and the control variables of the maneuvering execution sequence in a permutation and combination mode to obtain all permutation and combination results. In an embodiment, the sorting unit may be configured to perform the operation S2231 described above, which is not described herein again. And
and the generating unit is used for generating a control trigger sequence result set according to the fixed execution sequence and the permutation and combination result. In an embodiment, the generating unit may be configured to perform the operation S2232 described above, which is not described herein again.
According to an embodiment of the present disclosure, the second determining module 830 includes: the second obtaining submodule, the third determining submodule and the fourth determining submodule.
And the second obtaining sub-module is used for obtaining all control variables of the interface script template. In an embodiment, the second obtaining submodule may be configured to perform the operation S231 described above, and details are not described herein again.
And the third determining submodule is used for determining the input set of the control variable according to the test scene and an equivalence class dividing method. In an embodiment, the third determining submodule may be configured to perform operation S232 described above, and is not described herein again.
And the fourth determining submodule is used for carrying out Cartesian product operation on the input set of the control variables to determine a control input result set. In an embodiment, the fourth determining submodule may be configured to perform operation S233 described above, and is not described herein again.
According to an embodiment of the present disclosure, the generation module 840 includes a traversal submodule.
And the traversal submodule is used for traversing the input data of the control input result set according to the triggering sequence result of the control triggering sequence result set in sequence so as to generate a test script set of the interface to be tested. In an embodiment, the traversal submodule may be configured to perform the operation S241 described above, and details are not repeated here.
According to an embodiment of the present disclosure, any plurality of the obtaining module 810, the first determining module 820, the second determining module 830, and the generating module 840 may be combined into one module to be implemented, or any one of the modules may be split into a plurality of 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 the other modules and implemented in one module. According to an embodiment of the disclosure, at least one of the obtaining module 810, the first determining module 820, the second determining module 830, and the generating module 840 may be implemented at least partially as a hardware circuit, 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 a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or in any one of three implementations of software, hardware, and firmware, or in a suitable combination of any of them. Alternatively, at least one of the obtaining module 810, the first determining module 820, the second determining module 830 and the generating module 840 may be at least partially implemented as a computer program module, which when executed may perform a corresponding function.
FIG. 8 schematically illustrates a block diagram of an electronic device suitable for implementing a test script generation method according to an embodiment of the present disclosure.
As shown in fig. 8, an electronic apparatus 900 according to an embodiment of the present disclosure includes a processor 901 which can perform various appropriate actions and processes in accordance with 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. Processor 901 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 901 may also include on-board memory for caching purposes. The processor 901 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 903, various programs and data necessary for the operation of the electronic apparatus 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. The processor 901 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 902 and/or the RAM 903. Note that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 900 may also include input/output (I/O) interface 905, input/output (I/O) interface 905 also connected to bus 904, according to an embodiment of the present disclosure. The electronic device 900 may also include one or more of the following components connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement a test script generation method according to an embodiment of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 902 and/or the RAM 903 described above and/or one or more memories other than the ROM 902 and the RAM 903.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated by the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the test script generation method provided by the embodiment of the disclosure.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 901. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of a signal on a network medium, and downloaded and installed through the communication section 909 and/or installed from the removable medium 911. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program, when executed by the processor 901, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In situations involving remote computing devices, the remote computing devices may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to external computing devices (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It will be appreciated by a person skilled in the art that various combinations or/and combinations of features recited in the various embodiments of the disclosure and/or in the claims may be made, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments of the present disclosure and/or the claims may be made without departing from the spirit and teachings of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the disclosure, and these alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (10)

1. A test script generation method, comprising:
acquiring an interface test script template of an interface to be tested, wherein the interface test script template is generated by recording, clicking and recording a control in the interface to be tested;
performing strategy-based exploratory testing on the interface testing script template to determine a control triggering sequence result set;
performing scene-based exploratory test on the interface test script template to determine a control input result set; and
and generating a test script set of the interface to be tested according to the control triggering sequence result set and the control input result set.
2. The method of claim 1, wherein performing a policy-based heuristic test on the interface test script template to determine a control trigger order result set comprises:
acquiring all control elements of the interface script template, wherein the control elements comprise control variables and control constants;
determining a control execution sequence according to a preset test strategy and the control element, wherein the control execution sequence comprises a fixed execution sequence and a maneuvering execution sequence; and
and determining a control trigger sequence result set according to the fixed execution sequence and the maneuvering execution sequence, wherein the trigger sequence result set is a set of a plurality of sequence result test scripts.
3. The method of claim 2, wherein determining a control-triggered order result set from the fixed execution order and the maneuver execution order comprises:
the control constants and the control variables of the maneuvering execution sequence are sequenced in a permutation and combination mode to obtain all permutation and combination results; and
and generating a control trigger sequence result set according to the fixed execution sequence and the permutation and combination result.
4. The method of claim 1, wherein the scenario-based exploratory testing of the interface test script template to determine a control input result set comprises:
acquiring all control variables of the interface script template;
determining an input set of the control variables according to a test scene and an equivalence class division method; and
and carrying out Cartesian product operation on the input set of the control variables to determine a control input result set.
5. The method of claim 1, wherein generating the set of test scripts for the interface to be tested according to the set of control trigger order results and the set of control input results comprises:
and traversing the input data of the control input result set according to the triggering sequence result of the control triggering sequence result set in sequence to generate a test script set of the interface to be tested.
6. The method of any one of claims 1 to 5, after generating the test script set of the interface to be tested, further comprising:
inserting an assertion into each test script of the interface to be tested; and
and outputting an assertion test result after the test script is executed.
7. A test script generating apparatus comprising:
the acquisition module is used for acquiring an interface test script template of the interface to be tested, wherein the interface test script template is generated by recording and clicking a control which is input into the interface to be tested;
the first determining module is used for carrying out strategy-based exploratory testing on the interface testing script template so as to determine a control triggering sequence result set;
the second determination module is used for carrying out scene-based exploratory test on the interface test script template so as to determine a control input result set; and
and the generating module is used for generating a test script set of the interface to be tested according to the control triggering sequence result set and the control input result set.
8. An electronic device, comprising:
one or more processors;
a storage device to store one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-6.
9. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 6.
10. A computer program product comprising a computer program which, when executed by a processor, carries out the method according to any one of claims 1 to 6.
CN202210744949.7A 2022-06-27 2022-06-27 Test script generation method, device, equipment, storage medium and program product Pending CN115292157A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210744949.7A CN115292157A (en) 2022-06-27 2022-06-27 Test script generation method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210744949.7A CN115292157A (en) 2022-06-27 2022-06-27 Test script generation method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN115292157A true CN115292157A (en) 2022-11-04

Family

ID=83820494

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210744949.7A Pending CN115292157A (en) 2022-06-27 2022-06-27 Test script generation method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN115292157A (en)

Similar Documents

Publication Publication Date Title
US10120783B2 (en) Determining test case efficiency
US11501655B2 (en) Automated skill tagging, knowledge graph, and customized assessment and exercise generation
US20200210848A1 (en) Deep learning testing
CN110414989A (en) Method for detecting abnormality and device, electronic equipment and computer readable storage medium
WO2021104387A1 (en) Method for automatically identifying valid data acquisition module and system
CN113449877A (en) Method and system for displaying machine learning modeling process
CN113032257A (en) Automatic test method, device, computer system and readable storage medium
CN116720489B (en) Page filling method and device, electronic equipment and computer readable storage medium
EP4138004A1 (en) Method and apparatus for assisting machine learning model to go online
CN113535577A (en) Application testing method and device based on knowledge graph, electronic equipment and medium
CN111930629A (en) Page testing method and device, electronic equipment and storage medium
CN108664610B (en) Method and apparatus for processing data
CN116841898A (en) Test case and test script generation method, device, system and medium
CN110544166A (en) Sample generation method, device and storage medium
CN114968821A (en) Test data generation method and device based on reinforcement learning
CN115292157A (en) Test script generation method, device, equipment, storage medium and program product
CN115953234A (en) Risk assessment method and device, electronic equipment and storage medium
CN113157572B (en) Test case generation method, system, electronic equipment and storage medium
CN114791885A (en) Interface test method, device, equipment and medium
CN113190509A (en) Animation processing method and device, electronic equipment and computer readable storage medium
CN110879868A (en) Consultant scheme generation method, device, system, electronic equipment and medium
CN113032256A (en) Automatic test method, device, computer system and readable storage medium
CN114365151A (en) Neural network model transformation method, device, server and storage medium
CN116976885A (en) Training method of object recognition and recognition model and related device
CN115687079A (en) Test script public code generation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination