CN117909234A - Mobile terminal automatic test method and system based on natural language recognition - Google Patents

Mobile terminal automatic test method and system based on natural language recognition Download PDF

Info

Publication number
CN117909234A
CN117909234A CN202410074987.5A CN202410074987A CN117909234A CN 117909234 A CN117909234 A CN 117909234A CN 202410074987 A CN202410074987 A CN 202410074987A CN 117909234 A CN117909234 A CN 117909234A
Authority
CN
China
Prior art keywords
test
natural language
module
case
interceptors
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
CN202410074987.5A
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.)
Xiamen Huanqu Information Technology Co ltd
Xiamen Seal Cloud Information Technology Co ltd
Xiamen Shequ Information Technology Co ltd
Original Assignee
Xiamen Huanqu Information Technology Co ltd
Xiamen Seal Cloud Information Technology Co ltd
Xiamen Shequ Information Technology Co ltd
Filing date
Publication date
Application filed by Xiamen Huanqu Information Technology Co ltd, Xiamen Seal Cloud Information Technology Co ltd, Xiamen Shequ Information Technology Co ltd filed Critical Xiamen Huanqu Information Technology Co ltd
Publication of CN117909234A publication Critical patent/CN117909234A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a mobile terminal automatic test method and a system based on natural language identification, wherein the method comprises the following steps: s1, configuring application information to be tested through an automatic test platform; s2, compiling test cases according to natural language and grammar rules, and defining element information in a UI interface of the application to be tested; s3, analyzing the test case, splitting the test case into a plurality of operations, and then respectively converting natural language in each operation into machine language to generate a case operation queue; s4, judging the grammar of the machine language of each operation in the use case operation queue, if the grammar is correct, entering a step S5, otherwise, stopping the operation; s5, starting system barrier-free service, opening the application to be tested, executing each operation in the use case operation queue, checking whether the operation executed currently is successful, and when all the operations are successfully executed or serious errors occur in the executed operations, completing the test and generating a test report.

Description

Mobile terminal automatic test method and system based on natural language recognition
Technical Field
The invention relates to the technical field of automatic testing, in particular to a mobile terminal automatic testing method and system based on natural language identification.
Background
The automatic testing of the mobile terminal software UI (User Interface) is to make the machine simulate the User behavior to operate so as to complete the testing of the User Interface. And the tester writes an automatic test case, and after the machine is operated, the machine performs correctness verification and provides a result. Through automated testing, repetitive work can be avoided, and labor testing cost is reduced.
The mobile terminal UI automatic test in the current market mainly utilizes Appium, uiAutomator, airtest and other automatic test tools, and needs to write cases by using Python, java and other programming languages, so that the requirements on the programming capability of testers are high, and the writing efficiency is low; meanwhile, the automatic testing tools also have the conditions that the automatic testing tools cannot operate independently, UI elements cannot be positioned directly, the hands are difficult to get up, and the like. In large-scale software engineering projects, the project updating iteration speed is generally high, the original functions can be guaranteed to normally run, and very high requirements are put on the efficiency and quality of testing. In the current environment, the use cases written in the programming language have the disadvantages of high cost, non-visual logic intention and difficult maintenance, particularly the UI structure is frequently changed, the element positioning is complicated, and the original use cases are extremely high in failure.
Disclosure of Invention
The invention aims to provide a mobile terminal automatic test method and system based on natural language recognition, which are used for solving the problems.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
the mobile terminal automatic test method based on natural language identification is realized based on an automatic test platform and comprises the following steps:
s1, configuring application information to be tested through an automatic test platform;
S2, compiling test cases according to natural language and grammar rules, and defining element information in a UI interface of the application to be tested;
S3, analyzing the test case, splitting the test case into a plurality of operations, and then respectively converting natural language in each operation into machine language to generate a case operation queue;
S4, judging the grammar of the machine language of each operation in the use case operation queue, if the grammar is correct, entering a step S5, otherwise, stopping the operation;
S5, starting system barrier-free service, opening the application to be tested, executing each operation in the use case operation queue, checking whether the operation executed currently is successful, and when all the operations are successfully executed or serious errors occur in the executed operations, completing the test and generating a test report.
Preferably, the test case adopts a plain text format file, and each row in the plain text format file represents one operation.
Preferably, the automated test platform is provided with a case interceptor group, the case interceptor group comprises a plurality of interceptors, the interceptors are composed of interception rules, and the interception rules correspond to grammar rules when writing test cases.
Preferably, step S3 is embodied as
S31, starting text analysis, and analyzing the test case into a plurality of operations;
S32, analyzing UI element information corresponding to each operation and variable value information corresponding to the elements;
s33, starting a use case interceptor group, traversing all interceptors in the interceptor group by each operation in the test use case, searching interceptors corresponding to own conditions, and converting natural language in the operation into machine language through the searched interceptors;
s34, judging whether operation which does not execute analysis exists, if so, returning to the step S32 to continue analysis until all operations are executed, generating a use case operation queue, and issuing to judge grammar and execute operation.
Preferably, step S5 is specifically:
S51, opening a system barrier-free service and opening the application to be tested;
S52, respectively taking out each operation from the use case operation queue, executing the current operation, searching the interface element of the current UI, judging that the interface element is the target element required by the current operation if the interface element is matched with the target element attribute of the operation, and changing the operation state into an operation error if the matched interface element is not searched;
s53, executing element operation through the matched interface element of the barrier-free service, and generating a test report after the test is finished when all the operations are successfully executed or the executed operation errors are serious errors;
and S54, the test data of the test report are displayed through a test result page for a tester to analyze, and the analysis result is fed back to an application development end to be tested.
The mobile terminal automatic test system based on natural language identification comprises a case module, an execution set module, a device module, a natural language analysis module, a semantic module, a variable module, a setting module and a test report module, wherein the case module is used for compiling test cases through natural language and grammar rules, the execution set module is used for integrating a plurality of test cases into one execution set, the device module is used for acquiring device information and realizing single test of the plurality of test cases, the natural language analysis module is used for analyzing the test cases into machine language of machine identification, the semantic module is used for defining element information of a UI interface, the variable module is used for defining variable value information, the setting module is used for setting application information to be tested of automatic test, and the test report module is used for generating a test report from the execution result of the test cases or the execution set.
Preferably, the system further comprises a search module for searching test cases, execution sets and test reports.
Preferably, the natural language analysis module is internally provided with a case interceptor group, the case interceptor group comprises a plurality of interceptors, the interceptors are composed of interception rules, the interception rules correspond to grammar rules when test cases are written, when the natural language analysis module is used, each operation in the test cases traverses all interceptors in the interceptor group, the interceptors corresponding to the conditions are searched, and the natural language in the operation is converted into machine language through the searched interceptors.
After the technical scheme is adopted, compared with the background technology, the invention has the following beneficial effects:
1. The invention provides a mobile terminal automatic test method and a system based on natural language identification, which can write and use test cases without specific file types by using natural language and using simple and visual word description, are convenient to use, are easy to maintain, and can be rapidly compatible with scenes with frequent UI structure change.
2. The invention provides a mobile terminal automatic test method and a system based on natural language identification, which do not need to be connected with a computer PC terminal, all operations are completed in an automatic test platform application, each device can independently write use cases and operate, wireless is realized, and during operation, a barrier-free service operation UI built in an Android system is directly used, so that the time consumption of operation of processing and conversion of a third-party tool is avoided.
3. The invention provides a mobile terminal automatic test method and a system based on natural language identification, wherein a test report is generated by a test case, the test report can be exported and checked on any equipment, and meanwhile, the mobile terminal automatic test method and the system have error information highlighting prompt, so that the problem can be conveniently analyzed by test staff.
Drawings
FIG. 1 is a process step diagram of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the following examples in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Examples
The invention discloses a mobile terminal automatic test method based on natural language identification, which is realized based on an automatic test platform and specifically comprises the following steps of:
S1, configuring application information to be tested through an automatic test platform, wherein the application information to be tested comprises application names to be tested, whether to restart the application to be tested when starting running, whether to open a floating window and the like;
S2, writing a test case through natural language and a certain grammar rule, wherein the test case comprises a case name and a case description, and defining element information in a UI interface of an application to be tested, and the element information comprises description and positioning of UI elements;
The test case can be written directly on the automatic test platform of the embodiment, and can also be written on other platforms (such as a computer (PC) end), and after the writing of the other platforms is completed, the content of the test case needs to be copied into the application of the platform so as to be executed; and writing corresponding test case sentences according to the example sentence specifications by using a case operation writing panel, wherein each row of sentences is one operation.
The test cases are written in plain text format files, and each row in the plain text format files represents one operation.
S3, analyzing the test case, splitting the test case into a plurality of operations, and then respectively converting natural language in each operation into machine language to generate a case operation queue;
Step S3 is specifically as follows
S31, starting text analysis, and analyzing the test case into a plurality of operations;
S32, analyzing UI element information corresponding to each operation and variable value information corresponding to the elements;
S33, starting a case interceptor group, traversing all interceptors in the interceptor group by each operation in the test case, searching interceptors corresponding to own conditions, and converting natural language in operation into machine language through the searched interceptors;
s34, judging whether operation which does not execute analysis exists, if so, returning to the step S32 to continue analysis until all operations are executed, generating a use case operation queue, and issuing to judge grammar and execute operation.
S4, judging grammar of machine language of each operation in the use case operation queue, if the grammar is correct, entering a step S5, otherwise, stopping operation;
s5, starting a system barrier-free service, opening an application to be tested, executing each operation in the use case operation queue, checking whether the operation executed currently is successful, and when all the operations are successfully executed or serious errors occur in the executed operations, completing the test and generating a test report.
The automatic test platform is provided with a case interceptor group, the case interceptor group comprises a plurality of interceptors, each interceptor comprises interception rules, and the interception rules correspond to grammar rules when test cases are written.
The step S5 specifically comprises the following steps:
S51, starting system barrier-free service and opening an application to be tested;
S52, respectively taking out each operation from the use case operation queue, executing the current operation, searching the interface element of the current UI, judging that the interface element is the target element required by the current operation if the interface element is matched with the attribute of the target element of the operation, and changing the operation state into an operation error if the matched interface element is not searched;
s53, executing element operation through the matched interface element of the barrier-free service, and generating a test report after the test is finished when all the operations are successfully executed or the executed operation errors are serious errors;
For example, execute statements: if the return button # exists and then the return button is clicked, # the automatic test platform firstly judges whether a return button element exists in the current UI, the UI element is searched according to Text, description, className, xpath and ResId attributes of the element, if the target element is consistent with the text of a certain element on the current page, the two elements accord with initial conditions, the elements are judged and found out to be the most relevant element through ResId or other attributes, the elements are considered to be the elements needing to be operated in a use case, and when the matched element is not found, the operation state is changed into an execution error; when a matching element is found, clicking on the element is performed by the barrier-free service.
And S54, displaying the test data of the test report through a test result page for a tester to analyze, and feeding back an analysis result to an application development end to be tested. The data provided by the test case result page contains each operation screen shot, running time, equipment information, error information and the like.
The following test cases written in natural language are enumerated:
(1) Cold start
(2) Inputting # mobile phone number in the first input box
(3) Inputting a # password in a second input box
(4) Click immediate login
(5) Wait for 5 seconds
(6) Presence indication of successful login
The following is a detailed explanation based on the test case examples described above:
For example, in the interceptor parsing to example (2) above, the platform first determines that there is an "input#" statement, indicating that it needs to be parsed into InputAction of machines; next, extracting the sentence "in the first input box" before "input #" and identifying the core content "first", indicating that the element object to be operated is the first in the UI layer distribution; finally, the sentence "mobile phone number" after "input #" is extracted, which indicates that the content to be input is three words of "mobile phone number". So far, after the analysis of the line of sentences is finished, the line of sentences is converted into machine language, and the interceptor completes work and waits for subsequent operation. Through the converted machine language, when the system starts to run to the operation, the system firstly searches the first element which is an input box in the current page UI distribution from left to right and from top to bottom, and three words of a mobile phone number are automatically input in the input box after the first element is found, so that the line of operation examples are completed.
For example, upon the interceptor parsing to example (4) above, the interceptor responsible for the click event matches the rule: the statement starts with a "click". (4) The operation satisfies the rule indicating a need to be handled by the click event interceptor. Then, the post-sentence part is "immediate login", which means that the name of the target element requiring the operation is "immediate login". After the analysis of the line of sentences is completed, converting the natural language into a machine language, clicking the event machine language into ClickAction, and storing the machine language into a queue.
For example, when the interceptor parses the operation in the example (5) above, the interceptor is responsible for waiting for the event interceptor matching rule to be a regular expression, satisfying the expression condition, the platform parses the interceptor matching rule to be a waiting operation, sets the waiting time to be 5 seconds, and when executing the statement, the platform does not perform any operation, and executes the next operation after 5 seconds.
The rule syntax includes, but is not limited to (below X is the UI control element name): basic element operation grammar such as 'click X', 'double click X', 'long press X', 'slide X', 'return', and the like; element positioning grammars of 'first', 'last', 'any' and the like; logic judgment grammars such as "x# and then #," # is equal to or greater than #, "# text is equal #", and the like if present; variable assignment grammar such as "user nickname=hello", "variable name=get text X". All the rules grammars currently defined meet the operational requirements required for current automated testing.
The invention also discloses a mobile terminal automatic test system based on natural language identification, which comprises a case module, an execution set module, an equipment module, a natural language analysis module, a semantic module, a variable module, a setting module and a test report module, wherein the case module is used for compiling test cases through natural language and a certain grammar rule and supporting the addition, the modification and the deletion of the test cases. The execution set module is used for integrating the plurality of test cases into one execution set, so that the plurality of test cases can be tested for a single time, and the equipment module is used for acquiring equipment information, wherein the equipment information comprises equipment hardware, configuration, version, resolution and the like. The method realizes single test of a plurality of test cases, the natural language analysis module is used for analyzing the test cases into machine language identified by a machine, and the semantic module is used for defining element information of a UI interface, so that the test cases can be conveniently written. For example, a menu button element may be defined as a "menu", and when an instance is written, a "menu" document may be directly used to operate a corresponding element, and if a button operation needs to be clicked, a "click menu" may be directly written, so that the platform may correspondingly operate the element. The variable module is used for defining variable value information, and can dynamically replace a required variable during operation. For example, the user name and the password required by login can be added into the variable, so that dynamic operation replacement can be realized in the use cases of the user name and the password, the original use cases are not required to be modified, and the test work is convenient. For example, a row of use case sentences is used for inputting # { user name }, the variable names are set as user names in advance through the variable module, and the variable values are set as userName, so that the natural language analysis module can directly obtain the variable values through the variable module, and the replacement of the "# { user name }" variables in the sentences is completed. The setting module is used for setting the application information to be tested of the automatic test, and comprises an application name to be tested, whether to restart the application to be tested when starting running, whether to open a floating window and the like. The test report module is used for generating a test report from the execution result of the test case or the execution set, and comprises a screen shot of each operation, wrong operation information, equipment information, case execution duration information and the like. .
The system also comprises a search module which is used for searching the test cases, the execution sets and the test reports and can search through keywords such as case names, execution set names, semantic names, variable names and the like.
The natural language analysis module is internally provided with a case interceptor group, the case interceptor group comprises a plurality of interceptors, each interceptor is composed of an interceptor rule, the interceptor rule corresponds to a grammar rule when the test case is written, when the natural language analysis module is used, each operation in the test case traverses all interceptors in the interceptor group, the interceptors corresponding to the conditions of the interceptors are searched, and the natural language in the operation is converted into a machine language through the searched interceptors.
The present invention is not limited to the above-mentioned embodiments, and any changes or substitutions that can be easily understood by those skilled in the art within the technical scope of the present invention are intended to be included in the scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims (8)

1. The mobile terminal automatic test method based on natural language identification is characterized by being realized based on an automatic test platform and specifically comprising the following steps of:
s1, configuring application information to be tested through an automatic test platform;
S2, compiling test cases according to natural language and grammar rules, and defining element information in a UI interface of the application to be tested;
S3, analyzing the test case, splitting the test case into a plurality of operations, and then respectively converting natural language in each operation into machine language to generate a case operation queue;
S4, judging the grammar of the machine language of each operation in the use case operation queue, if the grammar is correct, entering a step S5, otherwise, stopping the operation;
S5, starting system barrier-free service, opening the application to be tested, executing each operation in the use case operation queue, checking whether the operation executed currently is successful, and when all the operations are successfully executed or serious errors occur in the executed operations, completing the test and generating a test report.
2. The mobile terminal automatic test method based on natural language identification as claimed in claim 1, wherein: the test case adopts a plain text format file, and each row in the plain text format file represents one operation.
3. The mobile terminal automatic test method based on natural language identification as claimed in claim 1, wherein: the automatic test platform is provided with a case interceptor group, the case interceptor group comprises a plurality of interceptors, the interceptors are composed of interception rules, and the interception rules correspond to grammar rules when test cases are written.
4. The mobile terminal automatic test method based on natural language identification as claimed in claim 3, wherein: step S3 is specifically as follows
S31, starting text analysis, and analyzing the test case into a plurality of operations;
S32, analyzing UI element information corresponding to each operation and variable value information corresponding to the elements;
s33, starting a use case interceptor group, traversing all interceptors in the interceptor group by each operation in the test use case, searching interceptors corresponding to own conditions, and converting natural language in the operation into machine language through the searched interceptors;
s34, judging whether operation which does not execute analysis exists, if so, returning to the step S32 to continue analysis until all operations are executed, generating a use case operation queue, and issuing to judge grammar and execute operation.
5. The mobile terminal automatic test method based on natural language identification as claimed in claim 1, wherein: the step S5 specifically comprises the following steps:
S51, opening a system barrier-free service and opening the application to be tested;
S52, respectively taking out each operation from the use case operation queue, executing the current operation, searching the interface element of the current UI, judging that the interface element is the target element required by the current operation if the interface element is matched with the target element attribute of the operation, and changing the operation state into an operation error if the matched interface element is not searched;
s53, executing element operation through the matched interface element of the barrier-free service, and generating a test report after the test is finished when all the operations are successfully executed or the executed operation errors are serious errors;
and S54, the test data of the test report are displayed through a test result page for a tester to analyze, and the analysis result is fed back to an application development end to be tested.
6. The mobile-side automated testing system based on natural language recognition of any one of claims 1-5, wherein: the system comprises a case module, an execution set module, a device module, a natural language analysis module, a semantic module, a variable module, a setting module and a test report module, wherein the case module is used for compiling test cases through natural language and grammar rules, the execution set module is used for integrating a plurality of test cases into one execution set, the device module is used for acquiring device information and realizing single test of the plurality of test cases, the natural language analysis module is used for analyzing the test cases into machine language recognized by a machine, the semantic module is used for defining element information of a UI interface, the variable module is used for defining variable value information, the setting module is used for setting application information to be tested for automatic test, and the test report module is used for generating a test report from the execution result of the test cases or the execution set.
7. The mobile terminal automated test system based on natural language recognition of claim 6, wherein: the system also comprises a search module, wherein the search module is used for searching test cases, execution sets and test reports.
8. The mobile terminal automated test system based on natural language recognition of claim 6, wherein: the natural language analysis module is internally provided with a case interceptor group, the case interceptor group comprises a plurality of interceptors, the interceptors are composed of interception rules, the interception rules correspond to grammar rules when test cases are written, when the natural language analysis module is used, each operation in the test cases traverses all interceptors in the interceptor group, the interceptors corresponding to own conditions are searched, and the natural language in the operation is converted into machine language through the searched interceptors.
CN202410074987.5A 2024-01-18 Mobile terminal automatic test method and system based on natural language recognition Pending CN117909234A (en)

Publications (1)

Publication Number Publication Date
CN117909234A true CN117909234A (en) 2024-04-19

Family

ID=

Similar Documents

Publication Publication Date Title
US9928160B2 (en) Automatic pre-detection of potential coding issues and recommendation for resolution actions
KR0125774B1 (en) Method and system for language translation within an interactive software application
US7100150B2 (en) Method and apparatus for testing embedded examples in GUI documentation
US8875110B2 (en) Code inspection executing system for performing a code inspection of ABAP source codes
US7191326B2 (en) Method and apparatus for making and using test verbs
US8875103B2 (en) Method of testing multiple language versions of a software system using one test script
JPH0630057B2 (en) Interactive software testing equipment
CN110347598B (en) Test script generation method and device, server and storage medium
JP2009519534A (en) Text editing apparatus and method
CN112328489B (en) Test case generation method and device, terminal equipment and storage medium
US20070061641A1 (en) Apparatus and method for generating test driver
CN112882408B (en) Online editing method and device for ST text language
CN102479152A (en) Method and device for obtaining tool automatic test results on basis of Android platform
CN111694738B (en) Method for generating SQL test script
CN113032279A (en) Web application testing and repairing method based on semantic path search
CN112270197A (en) Animation draft generation method and device based on character paragraphs
CN117909234A (en) Mobile terminal automatic test method and system based on natural language recognition
CN113051262B (en) Data quality inspection method, device, equipment and storage medium
CN111984536A (en) Equipment automation test system
CN114297057A (en) Design and use method of automatic test case
US7318221B2 (en) Windows™ F-language interpreter
CN113806230A (en) Software testing method, device, equipment and medium based on case voice
CN112965909A (en) Test data, test case generation method and system, and storage medium
CN113807077A (en) Natural language test script parsing processing method and device and electronic equipment
CN113064811A (en) Workflow-based automatic testing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication