CN112860587B - UI automatic test method and device - Google Patents

UI automatic test method and device Download PDF

Info

Publication number
CN112860587B
CN112860587B CN202110364727.8A CN202110364727A CN112860587B CN 112860587 B CN112860587 B CN 112860587B CN 202110364727 A CN202110364727 A CN 202110364727A CN 112860587 B CN112860587 B CN 112860587B
Authority
CN
China
Prior art keywords
test
program
target
use case
parameters
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.)
Active
Application number
CN202110364727.8A
Other languages
Chinese (zh)
Other versions
CN112860587A (en
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 CN202110364727.8A priority Critical patent/CN112860587B/en
Publication of CN112860587A publication Critical patent/CN112860587A/en
Application granted granted Critical
Publication of CN112860587B publication Critical patent/CN112860587B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

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 present disclosure provides a UI automatic test method, including: receiving a test request, wherein the test request indicates a User Interface (UI) control to be tested; analyzing a preset use case description file, and determining a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description; translating at least one test step in the target use case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target use case template; expanding the program primitives in the test program to form a test command which can be used for driving the simulation user operation; and executing the test command to perform test operation on the UI control, so as to obtain a test result. The disclosure also provides an automatic UI testing device, an electronic device and a computer storage medium.

Description

UI automatic test method and device
Technical Field
The disclosure relates to the technical field of testing, in particular to a UI automatic testing method and device.
Background
The UI (User Interface) automatic test is a technology for automatically testing a UI control of an application, and by executing an automatic test case, whether an actual test result is consistent with an expected test result is detected, so as to determine whether the UI control functions normally.
In the process of realizing the technical scheme, the inventor finds that the automatic test cases are mostly generated based on recording playback tools, and specifically, after the application program functions are deployed and realized, a tester uses the tools to record the application program functions so as to generate the automatic test cases. The method makes UI automatic test work seriously lag development, and in addition, the automatic test case generated based on the recording mode has the problem of high cost in convenient code maintenance.
Disclosure of Invention
One aspect of the present disclosure provides a UI automatic test method, including: receiving a test request, wherein the test request indicates a User Interface (UI) control to be tested; analyzing a preset use case description file, and determining a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description; translating at least one test step in the target use case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target use case template; expanding the program primitives in the test program to form a test command which can be used for driving the simulation user operation; and executing the test command to perform test operation on the UI control, so as to obtain a test result.
Optionally, the translating at least one test step in the target case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target case template includes: and translating user operation described by each test step aiming at the UI control into a program primitive based on the preset program language according to the logic sequence of the at least one test step to form the test program.
Optionally, the use case description file further includes a page element definition parameter based on natural language description, where the definition parameter includes at least an identification parameter, an acquisition path parameter, and an operation type parameter; the method further comprises the steps of: analyzing the use case description file, and determining a target page element associated with the UI control based on the definition parameters; translating each definition parameter aiming at the target page element into a program primitive based on a preset target program language to form a definition program aiming at the target page element; and executing the definition program to realize the construction of a test page based on the target page element.
Optionally, the executing the test command to perform a test operation for the UI control, to obtain a test result, includes: and executing the test command in the test page to realize the test operation of the UI control by simulating the user operation, so as to obtain a test result.
Optionally, the use case description file further includes a test data acquisition parameter based on natural language description, where the acquisition parameter includes at least an identification parameter and an acquisition path parameter; the method further comprises the steps of: analyzing the use case description file, and determining target test data for testing the UI control based on the acquisition parameters; translating each acquired parameter aiming at the target test data into a program primitive based on a preset target program language to form an acquired program aiming at the target test data; and executing the acquisition program to acquire target test data for testing the UI control.
Optionally, the target test data includes test entity parameters for testing the UI control; the expanding the program primitives in the test program to form a test command capable of being used for driving simulation user operation comprises the following steps: and replacing the test form parameters of the program primitives in the test program by using the test entity parameters in the target test data to obtain the test command.
Optionally, the use case description file further includes assertion definition parameters based on natural language description; the method further comprises the steps of: translating the assertion definition parameters into assertion primitives based on a preset target program language; executing the assertion primitive, and judging whether the test result is consistent with an expected test result; if yes, determining that the test result for the UI control is normal.
Another aspect of the present disclosure provides an UI automatic test equipment, including: the receiving module is used for receiving a test request, wherein the test request indicates a User Interface (UI) control to be tested; the first processing module is used for analyzing a preset use case description file and determining a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description; the second processing module is used for translating at least one testing step in the target case template into a program primitive based on a preset target program language to obtain a testing program corresponding to the target case template; the third processing module is used for expanding the program primitives in the test program to form a test command which can be used for driving the simulation user operation; and the fourth processing module is used for executing the test command to perform test operation on the UI control so as to obtain a test result.
Optionally, the second processing module includes: and the first processing submodule is used for translating the user operation described by each testing step aiming at the UI control into a program primitive based on the preset program language according to the logic sequence of the at least one testing step to form the testing program.
Optionally, the use case description file further includes a page element definition parameter based on natural language description, where the definition parameter includes at least an identification parameter, an acquisition path parameter, and an operation type parameter; the apparatus further comprises: a fifth processing module, configured to parse the use case description file, and determine a target page element associated with the UI control based on the definition parameter; translating each definition parameter aiming at the target page element into a program primitive based on a preset target program language to form a definition program aiming at the target page element; and executing the definition program to realize the construction of a test page based on the target page element.
Optionally, the fourth processing module includes: and the second processing sub-module is used for executing the test command in the test page so as to realize the test operation of the UI control by simulating the user operation and obtain a test result.
Optionally, the use case description file further includes a test data acquisition parameter based on natural language description, where the acquisition parameter includes at least an identification parameter and an acquisition path parameter; the apparatus further comprises: the sixth processing module is used for analyzing the use case description file and determining target test data for testing the UI control based on the acquisition parameters; translating each acquired parameter aiming at the target test data into a program primitive based on a preset target program language to form an acquired program aiming at the target test data; and executing the acquisition program to acquire target test data for testing the UI control.
Optionally, the target test data includes test entity parameters for testing the UI control; the third processing module includes: and the third processing sub-module is used for replacing the test form parameters of the program primitives in the test program by using the test entity parameters in the target test data to obtain the test command.
Optionally, the use case description file further includes assertion definition parameters based on natural language description; the apparatus further comprises: the seventh processing module is used for translating the assertion definition parameters into assertion program primitives based on a preset target program language; executing the assertion primitive, and judging whether the test result is consistent with an expected test result; if yes, determining that the test result for the UI control is normal.
Another aspect of the present disclosure provides an electronic device comprising one or more processors; and 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 implement the methods of embodiments of the present disclosure.
Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions that, when executed, are configured to implement a method of an embodiment of the present disclosure.
Another aspect of the present disclosure provides a computer program product comprising computer readable instructions, wherein the computer readable instructions, when executed, are for performing the UI automatic test method of the embodiments of the present disclosure.
Drawings
For a more complete understanding of the present disclosure, and the advantages thereof, reference is now made to the following descriptions taken in conjunction with the accompanying drawings, in which,
FIG. 1 schematically illustrates a system architecture of a UI automatic test method and apparatus according to an embodiment of the disclosure;
FIG. 2 schematically illustrates a flow chart of a UI automatic test method according to an embodiment of the disclosure;
FIG. 3 schematically illustrates a flow chart of another UI automatic test method according to an embodiment of the disclosure;
FIG. 4 schematically illustrates a flow chart of yet another UI automatic test method according to an embodiment of the disclosure;
FIG. 5 schematically illustrates a flow chart of yet another UI automatic test method according to an embodiment of the disclosure;
FIG. 6 schematically illustrates a schematic diagram of a UI automatic test system according to an embodiment of the disclosure;
FIG. 7 schematically illustrates a block diagram of a UI automatic test apparatus according to an embodiment of the disclosure;
fig. 8 schematically illustrates a block diagram of an electronic device according to an embodiment of the 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 intended by way of example only and is not intended to limit the scope of the 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 present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to 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, operations, and/or components, but do not preclude the presence or addition of one or more other features, 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 unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where expressions like at least one of "A, B and C, etc. are used, the expressions should generally be interpreted in accordance with the meaning as commonly understood by those skilled in the art (e.g.," a system having at least one of A, B and C "shall include, but not be limited to, a system having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
Some of the block diagrams and/or flowchart illustrations are shown in the figures. It will be understood that some blocks of the block diagrams and/or flowchart illustrations, or combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable UI automated test equipment, such that the instructions, when executed by the processor, create means for implementing the functions/acts specified in the block diagrams and/or flowchart. The techniques of this disclosure may be implemented in hardware and/or software (including firmware, microcode, etc.). Additionally, the techniques of this disclosure may take the form of a computer program product on a computer-readable storage medium having instructions stored thereon, the computer program product being for use by or in connection with an instruction execution system.
The embodiment of the disclosure provides an automatic UI testing method and a testing device capable of applying the method. The method specifically comprises the following steps of firstly, receiving a test request, wherein the test request indicates a user interface UI control to be tested, then, analyzing a preset use case description file to determine a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description, then, translating at least one test step in the target use case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target use case template, expanding the program primitive in the test program to form a test command for driving a simulated user operation, and finally, executing the test command to perform test operation on the UI control to obtain a test result.
Fig. 1 schematically illustrates a system architecture of a UI automatic test method and apparatus according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a system architecture to which embodiments of the present disclosure may be applied to assist those skilled in the art in understanding the technical content of the present disclosure, but does not mean that embodiments of the present disclosure may not be used in other devices, systems, environments, or scenarios.
As shown in fig. 1, the system architecture 100 includes a smart terminal (a plurality of smart terminals 101, 102, 103 are shown) and a test computer (a test computer 104, for example) that is communicatively connected to an application terminal. Firstly, the test computer 104 receives a test request, the test request indicates a UI control to be tested in an intelligent terminal (such as the intelligent terminals 101, 102 and 103), then, the test computer 104 analyzes a preset use case description file to determine a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description, next, the test computer 104 translates at least one test step in the target use case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target use case template, and expands the program primitive in the test program to form a test command for driving a simulation user operation, and finally, the test computer 104 executes the test command to perform the test operation for the UI control in the intelligent terminal (such as the intelligent terminals 101, 102 and 103) to obtain a test result.
It should be noted that the UI automatic test method and apparatus according to the embodiments of the present disclosure may be used in the financial field, and may also be used in any field other than the financial field. The disclosure will be described in detail below with reference to the drawings and specific examples.
Fig. 2 schematically illustrates a flow chart of a UI automatic test method according to an embodiment of the present disclosure, as illustrated in fig. 2, the method 200 may include operations S210-S250.
In operation S210, a test request is received, the test request indicating a user interface UI control to be tested.
In this embodiment, specifically, the test computer receives a test request, where the test request indicates a UI control to be tested in the intelligent terminal. The UI control may be any control on a UI interface of the intelligent terminal, and the intelligent terminal may include, for example, an electronic device such as a smart phone, a tablet computer, a smart television, a smart wearable device, and a smart robot. The UI control parameters to be tested are described in the test request, and the UI control parameters can comprise contents such as control names, control identification IDs, control position parameters, control function descriptions and the like. Automated testing for UI controls may include normal request testing and abnormal request testing.
Next, in operation S220, a preset use case description file is parsed to determine a target use case template for testing the UI control, wherein the use case description file includes at least one use case template based on a natural language description.
In this embodiment, specifically, the test computer determines a target use case template for testing the UI control by parsing a preset use case description file. The use case description file comprises at least one use case template based on natural language description, and the use case template comprises basic test information such as test types, test ranges, test steps, expected test results and the like.
The preset use case description file can be an EXCEL file, and a plurality of sharable use case templates based on natural language description are integrated in the use case description file in an XLS format. The case description file comprises a plurality of cells, and case templates for automatic testing are independently recorded in each cell. The different case templates can be in a non-coupling relation, the automatic test cases generated based on the different case templates are not mutually called in the executed process, and the test cases and the test results have a one-to-one correspondence relation. The shared case template for UI automatic test is managed through the case template form, and is described in a natural language mode, so that the professional requirement of UI automatic test is reduced, and the development cost of the automatic test case is controlled.
And according to the UI control parameters in the test request, determining a use case template meeting the UI control parameters by analyzing the use case description file. Optionally, in combination with the automatic test action described in the test request, in the use case templates meeting the UI control parameters, the use case templates meeting the requirements of the automatic test action are further screened to be used as target use case templates for testing the UI control.
Next, in operation S230, at least one test step in the target case template is translated into a program primitive based on a preset target program language, so as to obtain a test program corresponding to the target case template.
In this embodiment, specifically, since each case template in the case description file is described based on a natural language manner, the case template in the language format cannot be executed by a computer, so that, based on a preset target program language, according to a logic sequence of at least one test step in the target case template, user operations described by each test step and directed against the UI control can be translated into program primitives to form a test program. A program primitive is a program segment made up of several instructions that can be used to control a computer process to implement a particular function.
The automated testing for the UI control may be accomplished by driving the testing computer to simulate user operation, and thus the user operation for the UI control is described in the automated testing step. When the target use case template described based on the natural language mode is translated by utilizing the target program language, user operation described in each test step aiming at the UI control is translated into a program primitive according to grammar rules and preset sentence types of the target program language, so as to form a test program corresponding to the target use case template. The preset statement types may include, for example, an object operation type, a direct function call type, a tool class static function call type, and the like.
Next, in operation S240, program primitives in the test program are extended to form test commands that can be used to drive simulated user operations.
In the present embodiment, specifically, since the use case templates are separated from the test data, and further since the test program is formed based on the translation process for the target use case templates, the test entity parameters are not included in the program primitives of the test program, but only the test form parameters are included. The test form parameters are virtual variables that define the function names and function volumes, and there are no actual variables. The test entity parameters are actual parameters for automated testing, which have determined values. Illustratively, when testing the user login control of the UI interface, using the simulation input tool, the simulation user inputs login name "xiaoming", which is a test entity parameter for UI automatic test.
And expanding program primitives in the test program according to the test entity parameters for automatic test to form a test command capable of being used for driving simulation user operation. The test entity parameters may be derived based on test data for the UI control, and the source of the test data may be, for example, a pre-built test database, a user database with access rights, or may be obtained from a network using a data collection tool (e.g., a crawler tool).
The test data may include correct request parameters (e.g., when performing automated testing for a user login control, the test data may include a correct user name and password for simulating the user login), where the correct request parameters are used to test whether the UI control can return a correct response result under normal request conditions. In addition, the test data may further include an error request parameter (for example, when an automated test for the user login control is performed, the test data may further include an error user name or password for simulating the user login), where the error request parameter is used to test whether the UI control can perform an abnormal request error reporting in the case of abnormal request. The correct request parameter and the error request parameter can be used as test entity parameters for automatically testing the UI control, and can be used for verifying the integrity of the functional implementation of the UI control and verifying the rationality of fault tolerance processing of various abnormal conditions by carrying out normal logic test and error logic test on the UI control.
Next, in operation S250, a test command is executed to perform a test operation for the UI control, resulting in a test result.
In this embodiment, specifically, a test command is executed based on an automation manner by using an open-source automation operation framework, so as to perform a test operation for the UI control, and a test result is obtained. Optionally, by executing the test command, in the test page for the UI control, the user operation is simulated to input the request parameter (i.e., the test entity parameter), and then by triggering the interactive request option in the test page, the request parameter is sent to the system server. The action triggering the interaction request option may specifically be a clicking action, a selecting action or other touch actions. And after receiving the request parameters, the system server carries out logic processing to obtain an actual response result, wherein the actual response result forms an actual test result for the UI control.
Comparing the actual test result with a preset expected test result in a consistent manner, and judging that the automatic test aiming at the UI control passes when the actual test result is consistent with the expected test result; and when the actual test result is inconsistent with the expected test result, judging that the automatic test for the UI control fails.
By the embodiment of the disclosure, a test request is received, and the test request indicates a User Interface (UI) control to be tested; analyzing a preset use case description file to determine a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description; translating at least one test step in the target use case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target use case template; expanding program primitives in the test program to form a test command capable of driving simulated user operation; and executing the test command to perform test operation on the UI control, so as to obtain a test result. When automatic testing for the UI control is needed, determining a target use case template for testing the UI control in at least one use case template based on natural language description by analyzing the use case description file, and translating at least one testing step in the target use case template based on a preset target program language to form a testing command capable of driving simulated user operation. The method is beneficial to reducing the maintenance cost of the test case, realizing the UI automatic test method with low threshold, easy maintenance and no coding, improving the problem of serious hysteresis of UI automatic test work and greatly improving the UI automatic test efficiency.
Fig. 3 schematically illustrates a flowchart of another UI automatic test method according to an embodiment of the present disclosure, as illustrated in fig. 3, the method 300 further includes operations S310 to S340 in addition to operations S210 to S240.
In operation S310, a case description file is parsed, and a target page element associated with the UI control is determined based on definition parameters, wherein the case description file includes page element definition parameters based on natural language description, the definition parameters including at least an identification parameter, an acquisition path parameter, and an operation type parameter.
Next, in operation S320, each definition parameter for the target page element is translated into a program primitive based on a preset target program language, forming a definition program for the target page element.
Next, in operation S330, a definition program is executed to implement building a test page based on the target page element.
Next, in operation S340, a test command is executed in the test page to implement a test operation for the UI control by simulating a user operation, resulting in a test result.
In this embodiment, specifically, the use case description file includes page element definition parameters based on natural language description, where the definition parameters include at least an identification parameter, an acquisition path parameter, and an operation type parameter. The identification parameters may include, for example, an element Name (e.g., element name=user Name), an element identification ID (e.g., element identification id= "User Name ID"), and the like. The operation type parameter indicates the type of operation that can be performed on the page element, and may include, for example, a click operation (keyword is click), an input operation (keyword is set). The method comprises the steps of defining identification parameters of page elements in a natural language mode in a use case description file, defining path information for acquiring the page elements, and defining operation types which can be performed on the page elements. In practical applications, the definition parameters associated with the page elements may be modified during application development according to practical situations.
And analyzing the use case description file, and determining a target page element associated with the UI control according to each definition parameter aiming at the page element. Illustratively, the UI control to be tested is a user login control of the mobile banking APP, and the target page element associated with the UI control is determined to include a button component (key is button), an input box component (key is webEdit), and the like according to the identification parameter and the operation type parameter for the page element. Based on the target program language, each definition parameter for the target page element is translated into a program primitive to form a definition program for the target page element. By executing the definition program, the method comprises the steps of obtaining target page elements according to each definition parameter after translation, and constructing a test page of a target program language class based on the target page elements, for example, constructing a Java class test page. Executing the test command in the constructed test page, and performing test operation on the UI control by simulating user operation to obtain a test result.
Fig. 4 schematically illustrates a flowchart of yet another UI automatic test method according to an embodiment of the present disclosure, as illustrated in fig. 4, the method 400 includes operations S410 to S440 in addition to operations S210 to S230, S250.
In operation S410, a case description file is parsed, and target test data for testing the UI control is determined based on acquisition parameters, wherein the case description file includes test data acquisition parameters based on natural language description, and the acquisition parameters include at least identification parameters and acquisition path parameters.
Next, in operation S420, each acquisition parameter for the target test data is translated into a program primitive based on a preset target program language, forming an acquisition program for the target test data.
Next, in operation S430, an acquisition program is executed to acquire target test data for testing the UI control.
And, in operation S440, the test form parameters of the program primitives in the test program are replaced with the test entity parameters in the target test data to obtain the test command.
In this embodiment, the test data is specifically data that needs to be utilized by an automated test procedure, and the test data may include, for example, an interactive request parameter, which may include a correct request parameter and an error request parameter. The use case description file comprises test data acquisition parameters based on natural language description, wherein the acquisition parameters at least comprise identification parameters and acquisition path parameters. The identification parameters may include, for example, a test data name (e.g., test data name=testfile. Xls), and the acquisition path parameter indicates a path parameter (e.g., path parameter=d: \program files\test) for acquiring the test data.
Analyzing the case description file, and determining target test data for testing the UI control according to the acquisition parameters associated with the test data. And translating the acquisition parameters associated with the target test data into program primitives based on the target program language to form an acquisition program for the target test data. And executing the acquisition program in an automatic mode, and acquiring target test data according to each translated acquisition parameter. The target test data comprises test entity parameters for testing the UI control, and test form parameters of program primitives in the test program are replaced by the test entity parameters to obtain a test command.
Fig. 5 schematically illustrates a flowchart of yet another UI automatic test method according to an embodiment of the present disclosure, as illustrated in fig. 5, the method 500 further includes operations S510 to S520 in addition to operations S210 to S250.
In operation S510, based on a preset target program language, the assertion definition parameters described based on the natural language in the use case description file are translated into assertion primitives.
Next, in operation S520, an asserting program primitive is executed, whether the test result is consistent with the expected test result is judged, and if so, it is determined that the test result for the UI control is normal.
In this embodiment, specifically, the use case description file includes an assertion definition parameter based on a natural language description, and the assertion definition parameter is used to verify a test execution result. The assertion definition parameter indicates what character appears in what scene or test page based on which to determine to get the correct response result or the exception request to report the error. Illustratively, the assertion definition parameter indicates that when a "xxx user welcome you" or "login success" character appears in the test page, a simulated user login success is determined.
In the use case description file, the assertion definition parameters and the use case templates present an association record state. Analyzing the use case description file, and translating the assertion definition parameters based on natural language description in the use case description file to obtain the assertion primitive. Executing the assertion primitive to realize automatic verification of the test execution result, and the test execution result is the actual test result of the UI automatic test.
Fig. 6 schematically illustrates a schematic diagram of a UI automatic test system according to an embodiment of the present disclosure, and as shown in fig. 6, a test system 600 includes a case description file parsing module, a program language processing module, a case code generating module, a test execution module, and a log module.
The case description file analysis module: the system is used for analyzing the case description file, wherein the case description file comprises at least one case template based on natural language description, and comprises definition parameters for page elements, acquisition parameters for test data, assertion definition parameters associated with each case template and expected test results based on the natural language description.
And determining a target use case template for testing the UI control in at least one use case template based on the natural language description by analyzing the use case description file. In addition, the analysis of the use case description file is realized, the target page element associated with the UI control to be tested is determined, the target test data for testing the UI control is determined, and the assertion definition parameters and the expected test result associated with the target use case template are determined.
The program language processing module: the method is used for translating the case information described in the natural language mode based on a preset target program language. Specifically, the method is used for translating at least one test step in a target use case template into a program primitive, translating each definition parameter aiming at a target page element into the program primitive, translating each acquisition parameter aiming at target test data into the program primitive and translating an assertion definition parameter into an assertion program primitive based on a target program language.
The use case code generation module: and generating case code executable by the test computer based on the program primitives obtained by the translation process. Specifically, the method is used for generating a test program corresponding to the target use case template and expanding program primitives in the test program to form a test command for driving the simulation user operation. In addition, the method is also used for generating a definition program aiming at the target page element and generating an acquisition program aiming at target test data.
And the test execution module is used for: and the automatic test operation for the UI control is performed by executing the test command.
And a log module: the method is used for carrying out log record and exception handling on the generation progress of the use case file, and is convenient for testers to carry out result analysis on the use case generation condition of the UI automatic test process.
Fig. 7 schematically illustrates a block diagram of a UI automatic test equipment according to an embodiment of the present disclosure.
As shown in fig. 7, the apparatus 700 includes a receiving module 701, a first processing module 702, a second processing module 703, a third processing module 704, and a fourth processing module 705.
Specifically, the receiving module 701 is configured to receive a test request, where the test request indicates a UI control of a user interface to be tested; the first processing module 702 is configured to parse a preset use case description file, and determine a target use case template for testing the UI control, where the use case description file includes at least one use case template based on natural language description; a second processing module 703, configured to translate at least one test step in the target case template into a program primitive based on a preset target program language, so as to obtain a test program corresponding to the target case template; a third processing module 704, configured to extend program primitives in the test program to form a test command that can be used to drive a simulated user operation; the fourth processing module 705 is configured to execute the test command to perform a test operation for the UI control, so as to obtain a test result.
By the embodiment of the disclosure, a test request is received, and the test request indicates a User Interface (UI) control to be tested; analyzing a preset use case description file to determine a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description; translating at least one test step in the target use case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target use case template; expanding program primitives in the test program to form a test command capable of driving simulated user operation; and executing the test command to perform test operation on the UI control, so as to obtain a test result. When automatic testing for the UI control is needed, determining a target use case template for testing the UI control in at least one use case template based on natural language description by analyzing the use case description file, and translating at least one testing step in the target use case template based on a preset target program language to form a testing command capable of driving simulated user operation. The method is beneficial to reducing the maintenance cost of the test case, realizing the UI automatic test method with low threshold, easy maintenance and no coding, improving the problem of serious hysteresis of UI automatic test work and greatly improving the UI automatic test efficiency.
As a possible embodiment, the second processing module includes: the first processing sub-module is used for translating user operation described by each testing step aiming at the UI control into a program primitive based on a preset program language according to the logic sequence of at least one testing step to form a testing program.
As a possible embodiment, the use case description file further includes a page element definition parameter based on a natural language description, where the definition parameter includes at least an identification parameter, an acquisition path parameter, and an operation type parameter; the apparatus further comprises: the fifth processing module is used for analyzing the use case description file and determining target page elements associated with the UI control based on the definition parameters; translating each definition parameter aiming at the target page element into a program primitive based on a preset target program language to form a definition program aiming at the target page element; and executing a definition program to realize the construction of the test page based on the target page element.
As a possible embodiment, the fourth processing module includes: and the second processing sub-module is used for executing the test command in the test page so as to realize the test operation on the UI control by simulating the user operation and obtain a test result.
As a possible embodiment, the use case description file further includes test data acquisition parameters based on natural language description, where the acquisition parameters include at least an identification parameter and an acquisition path parameter; the apparatus further comprises: the sixth processing module is used for analyzing the use case description file and determining target test data for testing the UI control based on the acquisition parameters; translating each acquired parameter aiming at the target test data into a program primitive based on a preset target program language to form an acquired program aiming at the target test data; an acquisition procedure is performed to acquire target test data for testing the UI control.
As one possible embodiment, the target test data includes test entity parameters for testing the UI control; the third processing module includes: and the third processing submodule is used for replacing the test form parameters of the program primitives in the test program by using the test entity parameters in the target test data to obtain the test command.
As one possible embodiment, the use case description file also includes assertion definition parameters based on natural language descriptions; the apparatus further comprises: the seventh processing module is used for translating the assertion definition parameters into assertion primitives based on a preset target program language; executing the assertion primitive, and judging whether the test result is consistent with the expected test result; if yes, determining that the test result for the UI control is normal.
It should be noted that, in the embodiment of the present disclosure, the implementation manner of the device portion is the same as or similar to the implementation manner of the method portion, and will not be described herein.
Any number of the modules, or at least some of the functionality of any number, according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules according to embodiments of the present disclosure may be implemented as split into multiple modules. Any one or more of the modules according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system-on-chip, a system-on-a-substrate, a system-on-a-package, an Application Specific Integrated Circuit (ASIC), or in hardware or firmware in any other reasonable manner of integrating or packaging the circuits, or in any one of or in any suitable combination of three of software, hardware, and firmware. Or one or more of the modules according to embodiments of the present disclosure may be at least partially implemented as computer program modules that, when executed, perform the corresponding functions.
For example, any of the receiving module 701, the first processing module 702, the second processing module 703, the third processing module 704, and the fourth processing module 705 may be combined in one module to be implemented, or any of the modules may be split into a plurality of modules. Alternatively, at least some of the functionality of one or more of the modules may be combined with at least some of the functionality of other modules and implemented in one module. According to embodiments of the present disclosure, at least one of the receiving module 701, the first processing module 702, the second processing module 703, the third processing module 704, and the fourth processing module 705 may be implemented at least in part 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 a package, an Application Specific Integrated Circuit (ASIC), or as hardware or firmware in any other reasonable manner of integrating or packaging the circuitry, or as any one of or a suitable combination of three of software, hardware, and firmware. At least one of the receiving module 701, the first processing module 702, the second processing module 703, the third processing module 704 and the fourth processing module 705 may be at least partially implemented as computer program modules which, when executed, may perform the respective functions.
Fig. 8 schematically illustrates a block diagram of an electronic device according to an embodiment of the disclosure. The electronic device shown in fig. 8 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 8, the electronic device 800 includes a processor 810, a computer-readable storage medium 820. The electronic device 800 may perform methods according to embodiments of the present disclosure.
In particular, processor 810 may include, for example, a general purpose microprocessor, an instruction set processor and/or an associated chipset and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. Processor 810 may also include on-board memory for caching purposes. Processor 810 may be a single processing module or multiple processing modules for performing the different actions of the method flows according to embodiments of the disclosure.
Computer-readable storage medium 820, which may be, for example, a non-volatile computer-readable storage medium, specific examples include, but are not limited to: magnetic storage devices such as magnetic tape or hard disk (HDD); optical storage devices such as compact discs (CD-ROMs); a memory, such as a Random Access Memory (RAM) or a flash memory; etc.
The computer-readable storage medium 820 may comprise a computer program 821, which computer program 821 may comprise code/computer-executable instructions, which when executed by the processor 810, cause the processor 810 to perform a method according to an embodiment of the present disclosure or any variation thereof.
The computer program 821 may be configured with computer program code comprising, for example, computer program modules. For example, in an example embodiment, code in computer program 821 may include one or more program modules, including, for example, module 821A, module 821B. It should be noted that the division and number of modules is not fixed, and that a person skilled in the art may use suitable program modules or combinations of program modules according to the actual situation, which when executed by the processor 810, enable the processor 810 to perform the method according to the embodiments of the present disclosure or any variations thereof.
According to an embodiment of the present disclosure, at least one of the receiving module 701, the first processing module 702, the second processing module 703, the third processing module 704 and the fourth processing module 705 may be implemented as computer program modules described with reference to fig. 8, which when executed by the processor 810 may implement the respective operations described above.
The present disclosure also provides a computer-readable storage medium that may be embodied in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs which, when executed, implement methods in accordance with embodiments of the present disclosure.
The flowcharts 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 understood by those skilled in the art that while the present disclosure has been shown and described with reference to particular exemplary embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present disclosure as defined by the appended claims and their equivalents. The scope of the disclosure should, therefore, not be limited to the above-described embodiments, but should be determined not only by the following claims, but also by the equivalents of the following claims.

Claims (8)

1. An automatic UI test method, comprising:
receiving a test request, wherein the test request indicates a User Interface (UI) control to be tested;
analyzing a preset use case description file, and determining a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description;
translating at least one test step in the target use case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target use case template;
expanding the program primitives in the test program to form a test command which can be used for driving the simulation user operation;
analyzing the use case description file, and determining a target page element associated with the UI control based on definition parameters; the use case description file also comprises definition parameters of page elements based on natural language description; the definition parameters at least comprise identification parameters, acquisition path parameters and operation type parameters;
translating each definition parameter for the target page element into a program primitive based on the target program language to form a definition program for the target page element;
Executing the definition program to realize the construction of a test page based on the target page element;
executing the test command to perform a test operation for the UI control, to obtain a test result, including: executing the test command in the test page to realize the test operation of the UI control by simulating the user operation so as to obtain a test result; and simulating user operation input request parameters in the test page by executing the test command, and then sending the request parameters to a system server by triggering an interactive request option in the test page.
2. The method according to claim 1, wherein the translating at least one test step in the target case template into a program primitive based on a preset target program language to obtain a test program corresponding to the target case template includes:
and translating user operation described by each test step aiming at the UI control into a program primitive based on the target program language according to the logic sequence of the at least one test step to form the test program.
3. The method of claim 1, wherein,
The use case description file also comprises test data acquisition parameters based on natural language description, wherein the acquisition parameters at least comprise identification parameters and acquisition path parameters;
the method further comprises the steps of:
analyzing the use case description file, and determining target test data for testing the UI control based on the acquisition parameters;
translating each acquired parameter aiming at the target test data into a program primitive based on a preset target program language to form an acquired program aiming at the target test data;
and executing the acquisition program to acquire target test data for testing the UI control.
4. The method of claim 3, wherein,
the target test data comprises test entity parameters for testing the UI control;
the expanding the program primitives in the test program to form a test command capable of being used for driving simulation user operation comprises the following steps:
and replacing the test form parameters of the program primitives in the test program by using the test entity parameters in the target test data to obtain the test command.
5. The method of claim 1, wherein,
The use case description file also comprises assertion definition parameters based on natural language description;
the method further comprises the steps of:
translating the assertion definition parameters into assertion primitives based on a preset target program language;
executing the assertion primitive, and judging whether the test result is consistent with an expected test result; and
if yes, determining that the test result for the UI control is normal.
6. An UI automatic test equipment comprising:
the receiving module is used for receiving a test request, wherein the test request indicates a User Interface (UI) control to be tested;
the first processing module is used for analyzing a preset use case description file and determining a target use case template for testing the UI control, wherein the use case description file comprises at least one use case template based on natural language description;
the second processing module is used for translating at least one testing step in the target case template into a program primitive based on a preset target program language to obtain a testing program corresponding to the target case template;
the third processing module is used for expanding the program primitives in the test program to form a test command which can be used for driving the simulation user operation;
A fifth processing module for: analyzing the use case description file, and determining a target page element associated with the UI control based on definition parameters, wherein the use case description file further comprises definition parameters of the page element based on natural language description, and the definition parameters at least comprise identification parameters, acquisition path parameters and operation type parameters; translating each definition parameter for the target page element into a program primitive based on the target program language to form a definition program for the target page element; executing the definition program to realize the construction of a test page based on the target page element;
the fourth processing module is configured to execute the test command to perform a test operation for the UI control, to obtain a test result, and includes: executing the test command in the test page to realize the test operation of the UI control by simulating the user operation so as to obtain a test result; and simulating user operation input request parameters in the test page by executing the test command, and then sending the request parameters to a system server by triggering an interactive request option in the test page.
7. An electronic device, comprising:
one or more processors; and
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 implement the method of any of claims 1 to 5.
8. A computer readable storage medium having stored thereon executable instructions which when executed by a processor cause the processor to implement the method of any of claims 1 to 5.
CN202110364727.8A 2021-04-02 2021-04-02 UI automatic test method and device Active CN112860587B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110364727.8A CN112860587B (en) 2021-04-02 2021-04-02 UI automatic test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110364727.8A CN112860587B (en) 2021-04-02 2021-04-02 UI automatic test method and device

Publications (2)

Publication Number Publication Date
CN112860587A CN112860587A (en) 2021-05-28
CN112860587B true CN112860587B (en) 2024-04-05

Family

ID=75993288

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110364727.8A Active CN112860587B (en) 2021-04-02 2021-04-02 UI automatic test method and device

Country Status (1)

Country Link
CN (1) CN112860587B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113722214B (en) * 2021-08-16 2024-05-03 上海创米数联智能科技发展股份有限公司 Test method, test equipment and test system
CN113849416A (en) * 2021-10-29 2021-12-28 北京字节跳动网络技术有限公司 Test method, test device, storage medium and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598834A (en) * 2015-10-19 2017-04-26 腾讯科技(深圳)有限公司 UI (User Interface) testing method and device
CN109857652A (en) * 2019-01-16 2019-06-07 深圳壹账通智能科技有限公司 A kind of automated testing method of user interface, terminal device and medium
WO2020233331A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 User interface automated testing method and apparatus, and computer-readable storage medium
CN112416788A (en) * 2020-11-27 2021-02-26 中国科学院电子学研究所苏州研究院 Hierarchical standard Web application UI automatic test method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598834A (en) * 2015-10-19 2017-04-26 腾讯科技(深圳)有限公司 UI (User Interface) testing method and device
CN109857652A (en) * 2019-01-16 2019-06-07 深圳壹账通智能科技有限公司 A kind of automated testing method of user interface, terminal device and medium
WO2020233331A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 User interface automated testing method and apparatus, and computer-readable storage medium
CN112416788A (en) * 2020-11-27 2021-02-26 中国科学院电子学研究所苏州研究院 Hierarchical standard Web application UI automatic test method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
UI自动化测试技术在软件确认测试的研究与应用;刘泓辰;吕秀红;高超;刘春明;;自动化博览(第11期);全文 *

Also Published As

Publication number Publication date
CN112860587A (en) 2021-05-28

Similar Documents

Publication Publication Date Title
CN109871326B (en) Script recording method and device
CN108959068B (en) Software interface testing method, device and storage medium
US10176079B2 (en) Identification of elements of currently-executing component script
US9465718B2 (en) Filter generation for load testing managed environments
KR20210149045A (en) artificial intelligence chip verification
CN106446412B (en) Model-based test method for avionics system
CN111124919A (en) User interface testing method, device, equipment and storage medium
CN112860587B (en) UI automatic test method and device
US8745727B2 (en) Graphical user interface tester
CN110013672B (en) Method, device, apparatus and computer-readable storage medium for automated testing of machine-run games
CN112052172A (en) Rapid testing method and device for third-party channel and electronic equipment
CN111124870A (en) Interface testing method and device
CN110532182A (en) A kind of automated testing method and device of virtual platform
CN116069635A (en) SOC system testing method and device, computer equipment and storage medium
CN116166525A (en) Method and device for generating test script
EP3608786B1 (en) Systems and methods of requirements chaining and applications thereof
CN116629173A (en) Verification method and device of network chip, computer equipment and storage medium
CN115934559A (en) Testing method of intelligent form testing system
US20220269593A1 (en) Automatic generation of integrated test procedures using system test procedures
CN115687108A (en) Verification method, platform, terminal and storage medium based on combination of UVM and FPV
CN113836825A (en) Application method of key standard and verification chip of neural network processor
CN113886221A (en) Test script generation method and device, storage medium and electronic equipment
CN113986263A (en) Code automation test method, device, electronic equipment and storage medium
CN113868046A (en) Function verification method and system of PAD control unit and related components
CN114647568A (en) Automatic testing method and device, electronic equipment and readable storage medium

Legal Events

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