CN110737573A - Method and device for automatically testing user interface UI - Google Patents
Method and device for automatically testing user interface UI Download PDFInfo
- Publication number
- CN110737573A CN110737573A CN201810789737.4A CN201810789737A CN110737573A CN 110737573 A CN110737573 A CN 110737573A CN 201810789737 A CN201810789737 A CN 201810789737A CN 110737573 A CN110737573 A CN 110737573A
- Authority
- CN
- China
- Prior art keywords
- test
- instruction
- picture
- pictures
- case
- 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.)
- Granted
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 709
- 238000000034 method Methods 0.000 title claims abstract description 57
- 238000013507 mapping Methods 0.000 claims description 13
- 230000009191 jumping Effects 0.000 claims 1
- 230000008878 coupling Effects 0.000 abstract description 7
- 238000010168 coupling process Methods 0.000 abstract description 7
- 238000005859 coupling reaction Methods 0.000 abstract description 7
- 238000011835 investigation Methods 0.000 abstract description 7
- 230000004048 modification Effects 0.000 abstract description 5
- 238000012986 modification Methods 0.000 abstract description 5
- 238000010586 diagram Methods 0.000 description 6
- 238000007667 floating Methods 0.000 description 6
- 239000000725 suspension Substances 0.000 description 6
- 238000004590 computer program Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 230000004044 response Effects 0.000 description 4
- 230000008901 benefit Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 238000007689 inspection Methods 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 238000000429 assembly Methods 0.000 description 1
- 239000000969 carrier Substances 0.000 description 1
- 230000006870 function Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3696—Methods or tools to render software testable
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
本发明公开了用户界面UI自动化测试的方法和装置。所述方法包括:从测试用例的存储路径下读取测试用例;根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令;根据所述测试指令和相应的测试图片完成UI自动化测试。该技术方案基于对测试图片文件名的修改,实现了测试用例与测试图片的紧耦合,便于管理和测试结果排查,同时自动化测试的代码也可以按规律自动生成,方便使用。
The invention discloses a method and a device for automatic testing of user interface UI. The method includes: reading a test case from a storage path of the test case; generating a test instruction corresponding to each test image according to the file name of each test image in the test case; completing the UI according to the test instruction and the corresponding test image automated test. Based on the modification of the test image file name, the technical solution realizes the tight coupling of the test case and the test image, which is convenient for management and test result investigation, and at the same time, the code of the automated test can also be automatically generated according to the rules, which is convenient to use.
Description
技术领域technical field
本发明涉及自动化测试领域,具体涉及用户界面UI自动化测试的方法和装置。The invention relates to the field of automated testing, in particular to a method and a device for automated testing of user interface UI.
背景技术Background technique
以往UI(User Interface,用户界面)测试通常采用手工测试,费时费力。目前UI自动化测试有了良好的发展,但也存在很多不足,例如,在需要用到测试图片时,需要针对测试图片编写测试用例,测试用例和测试图片相分离,既不便于存储管理,也不便于测试结果的排查,同样不便于自动化测试代码的生成。In the past, UI (User Interface, user interface) testing was usually performed manually, which was time-consuming and labor-intensive. At present, UI automation testing has developed well, but there are also many shortcomings. For example, when test images are needed, test cases need to be written for the test images. The test cases and test images are separated, which is neither convenient for storage management nor It is convenient to check the test results, and it is also inconvenient to generate the automated test code.
发明内容SUMMARY OF THE INVENTION
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的用户界面UI自动化测试的方法和装置。In view of the above problems, the present invention is proposed in order to provide a method and apparatus for automatic testing of user interface UI which overcomes the above problems or at least partially solves the above problems.
依据本发明的一个方面,提供了一种用户界面UI自动化测试的方法,包括:According to one aspect of the present invention, a method for automated testing of user interface UI is provided, comprising:
从测试用例的存储路径下读取测试用例;Read the test case from the storage path of the test case;
根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令;Generate test instructions corresponding to each test image according to the file name of each test image in the test case;
根据所述测试指令和相应的测试图片完成UI自动化测试。The UI automation test is completed according to the test instruction and the corresponding test picture.
可选地,所述测试用例为包含若干个测试图片的文件夹。Optionally, the test case is a folder containing several test pictures.
可选地,所述测试图片的文件名中包括测试顺序的序列标识;Optionally, the filename of the test picture includes the sequence identifier of the test sequence;
所述从测试用例的存储路径下读取测试用例包括:The reading of the test case from the storage path of the test case includes:
按照序列标识从所述文件夹中读取测试图片,其中,每次读取一个测试图片,并在根据该测试图片完成相应的测试后,读取与测试顺序中下一个序列标识对应的测试图片,或者,根据测试结果确定新的序列标识,读取与新的序列标识对应的测试图片;Read the test pictures from the folder according to the sequence identifier, wherein one test image is read at a time, and after the corresponding test is completed according to the test image, the test image corresponding to the next sequence identifier in the test sequence is read , or, determine a new sequence identification according to the test result, and read the test picture corresponding to the new sequence identification;
当所述文件夹中的与测试顺序中最后一个序列标识对应的测试图片被读取完时结束UI自动化测试,或者,当根据一个测试图片的测试结果确定满足测试结束条件时,结束UI自动化测试。End the UI automation test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read, or, when it is determined according to the test result of a test picture that the test end condition is met, end the UI automation test .
可选地,测试图片的文件名中包括若干条测试信息,以及与各测试信息对应的标识;Optionally, the file name of the test picture includes several pieces of test information, and an identifier corresponding to each test information;
所述测试信息包括测试指令的伪指令和/或测试用数据。The test information includes pseudo-instructions of the test instructions and/or test data.
可选地,所述根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令包括:Optionally, generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case includes:
将测试图片的文件名读取为字符串,依序遍历字符串,获得各标识及与各标识对应的测试信息;Read the file name of the test image as a string, traverse the string in sequence, and obtain each logo and the test information corresponding to each logo;
根据所述测试信息中的伪指令查找测试指令映射表,查找出相应的测试指令。The test instruction mapping table is searched according to the pseudo-instruction in the test information, and the corresponding test instruction is found out.
可选地,所述测试指令包括如下的一种或多种:Optionally, the test instruction includes one or more of the following:
触发用户事件的指令,判断指令,跳转指令,测试时间设置指令。Instructions that trigger user events, judgment instructions, jump instructions, and test time setting instructions.
可选地,所述根据所述测试指令和相应的测试图片完成UI自动化测试包括:Optionally, completing the UI automation test according to the test instruction and the corresponding test picture includes:
对应用的UI进行截图,在截图中进行测试图片的识别;Take a screenshot of the UI of the application, and identify the test image in the screenshot;
根据图像识别结果和所述测试指令完成UI自动化测试。The UI automation test is completed according to the image recognition result and the test instruction.
可选地,该方法还包括:Optionally, the method further includes:
将UI自动化测试的测试结果和对应的测试用例保存至同一目录下。Save the test results of the UI automation test and the corresponding test cases to the same directory.
依据本发明的另一方面,提供了一种用户界面UI自动化测试的装置,包括:According to another aspect of the present invention, a device for automated testing of user interface UI is provided, comprising:
测试用例读取单元,适于从测试用例的存储路径下读取测试用例;The test case reading unit is suitable for reading the test case from the storage path of the test case;
测试指令生成单元,适于根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令;A test instruction generation unit, adapted to generate a test instruction corresponding to each test image according to the file name of each test image in the test case;
测试单元,适于根据所述测试指令和相应的测试图片完成UI自动化测试。The test unit is adapted to complete the UI automation test according to the test instruction and the corresponding test picture.
可选地,所述测试用例为包含若干个测试图片的文件夹。Optionally, the test case is a folder containing several test pictures.
可选地,所述测试图片的文件名中包括测试顺序的序列标识;Optionally, the filename of the test picture includes the sequence identifier of the test sequence;
所述测试用例读取单元,适于按照序列标识从所述文件夹中读取测试图片,其中,每次读取一个测试图片,并在根据该测试图片完成相应的测试后,读取与测试顺序中下一个序列标识对应的测试图片,或者,根据测试结果确定新的序列标识,读取与新的序列标识对应的测试图片;当所述文件夹中的与测试顺序中最后一个序列标识对应的测试图片被读取完时结束UI自动化测试,或者,当根据一个测试图片的测试结果确定满足测试结束条件时,结束UI自动化测试。The test case reading unit is adapted to read test pictures from the folder according to the sequence identifier, wherein one test picture is read at a time, and after the corresponding test is completed according to the test picture, read and test The test picture corresponding to the next sequence identification in the sequence, or, according to the test result, determine the new sequence identification, and read the test picture corresponding to the new sequence identification; when the last sequence identification in the folder corresponds to the last sequence identification in the test sequence End the UI automation test when the test picture of the test picture is read, or, when it is determined that the test end condition is satisfied according to the test result of a test picture, end the UI automation test.
可选地,测试图片的文件名中包括若干条测试信息,以及与各测试信息对应的标识;Optionally, the file name of the test picture includes several pieces of test information, and an identifier corresponding to each test information;
所述测试信息包括测试指令的伪指令和/或测试用数据。The test information includes pseudo-instructions of the test instructions and/or test data.
可选地,所述测试指令生成单元,适于将测试图片的文件名读取为字符串,依序遍历字符串,获得各标识及与各标识对应的测试信息;根据所述测试信息中的伪指令查找测试指令映射表,查找出相应的测试指令。Optionally, the test instruction generation unit is adapted to read the file name of the test picture as a character string, traverse the character string in sequence, and obtain each mark and test information corresponding to each mark; The pseudo-instruction searches the test instruction mapping table to find out the corresponding test instruction.
可选地,所述测试指令包括如下的一种或多种:Optionally, the test instruction includes one or more of the following:
触发用户事件的指令,判断指令,跳转指令,测试时间设置指令。Instructions that trigger user events, judgment instructions, jump instructions, and test time setting instructions.
可选地,所述测试单元,适于对应用的UI进行截图,在截图中进行测试图片的识别;根据图像识别结果和所述测试指令完成UI自动化测试。Optionally, the testing unit is adapted to take a screenshot of the UI of the application, and identify the test picture in the screenshot; complete the UI automation test according to the image recognition result and the test instruction.
可选地,所述测试单元,还适于将UI自动化测试的测试结果和对应的测试用例保存至同一目录下。Optionally, the test unit is further adapted to save the test result of the UI automation test and the corresponding test case in the same directory.
依据本发明的又一方面,提供了一种电子设备,包括:处理器;以及被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器执行如上述任一所述的方法。According to yet another aspect of the present invention, there is provided an electronic device comprising: a processor; and a memory arranged to store computer-executable instructions that, when executed, cause the processor to perform any of the above a described method.
依据本发明的再一方面,提供了一种计算机可读存储介质,其中,所述计算机可读存储介质存储一个或多个程序,所述一个或多个程序当被处理器执行时,实现如上述任一所述的方法。According to yet another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores one or more programs, the one or more programs, when executed by a processor, implements the following: Any of the methods described above.
由上述可知,本发明的技术方案,从测试用例的存储路径下读取测试用例,根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令,根据测试指令和相应的测试图片完成UI自动化测试。该技术方案基于对测试图片文件名的修改,实现了测试用例与测试图片的紧耦合,便于管理和测试结果排查,同时自动化测试的代码也可以按规律自动生成,方便使用。As can be seen from the above, the technical solution of the present invention reads the test case from the storage path of the test case, generates the test instruction corresponding to each test image according to the file name of each test image in the test case, and generates the test instruction corresponding to each test image according to the test instruction and the corresponding test. The picture completes the UI automation test. Based on the modification of the test image file name, the technical solution realizes the tight coupling between the test case and the test image, which is convenient for management and test result investigation, and at the same time, the code of the automated test can also be automatically generated according to the rules, which is convenient to use.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solutions of the present invention, in order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand , the following specific embodiments of the present invention are given.
附图说明Description of drawings
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are for the purpose of illustrating preferred embodiments only and are not to be considered limiting of the invention. Also, the same components are denoted by the same reference numerals throughout the drawings. In the attached image:
图1示出了根据本发明一个实施例的一种用户界面UI自动化测试的方法的流程示意图;1 shows a schematic flowchart of a method for automated testing of a user interface UI according to an embodiment of the present invention;
图2示出了根据本发明一个实施例的一种用户界面UI自动化测试的装置的结构示意图;2 shows a schematic structural diagram of an apparatus for automatic testing of user interface UI according to an embodiment of the present invention;
图3示出了根据本发明一个实施例的电子设备的结构示意图;FIG. 3 shows a schematic structural diagram of an electronic device according to an embodiment of the present invention;
图4示出了根据本发明一个实施例的计算机可读存储介质的结构示意图。FIG. 4 shows a schematic structural diagram of a computer-readable storage medium according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be more thoroughly understood, and will fully convey the scope of the present disclosure to those skilled in the art.
图1示出了根据本发明一个实施例的一种用户界面UI自动化测试的方法的流程示意图。如图1所示,该方法包括:FIG. 1 shows a schematic flowchart of a method for automated testing of a user interface UI according to an embodiment of the present invention. As shown in Figure 1, the method includes:
步骤S110,从测试用例的存储路径下读取测试用例。Step S110, read the test case from the storage path of the test case.
测试用例的含义通常要结合使用场景来分析,在本发明的实施例中,自动化测试代码是与测试用例分离的,但测试用例中也包含了测试逻辑。也就是说,测试用例包含有测试所使用的数据,以及测试逻辑的描述信息,但是不包含具体的执行指令。The meaning of the test case is usually analyzed in combination with the usage scenario. In the embodiment of the present invention, the automated test code is separated from the test case, but the test case also includes test logic. That is to say, the test case contains the data used by the test and the description information of the test logic, but does not contain specific execution instructions.
因此在步骤S120,根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令。Therefore, in step S120, a test instruction corresponding to each test picture is generated according to the file name of each test picture in the test case.
可以看出,文件名中包含有测试逻辑的描述信息,例如一个测试图片的图片内容描述了应用中的一个控件,文件名中描述了要对这个控件进行点击操作,那么测试指令就是根据这些来生成的。It can be seen that the file name contains description information of the test logic. For example, the image content of a test image describes a control in the application, and the file name describes the click operation on this control, then the test instruction is based on these Generated.
步骤S130,根据测试指令和相应的测试图片完成UI自动化测试。Step S130, the UI automation test is completed according to the test instruction and the corresponding test picture.
可见,图1所示的方法,从测试用例的存储路径下读取测试用例,根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令,根据测试指令和相应的测试图片完成UI自动化测试。该技术方案基于对测试图片文件名的修改,实现了测试用例与测试图片的紧耦合,便于管理和测试结果排查,同时自动化测试的代码也可以按规律自动生成,方便使用。It can be seen that in the method shown in Figure 1, the test case is read from the storage path of the test case, and the test instruction corresponding to each test image is generated according to the file name of each test image in the test case. According to the test instruction and the corresponding test image Complete UI automation testing. Based on the modification of the test image file name, the technical solution realizes the tight coupling between the test case and the test image, which is convenient for management and test result investigation, and at the same time, the code of the automated test can also be automatically generated according to the rules, which is convenient to use.
在本发明的一个实施例中,上述方法中,测试用例为包含若干个测试图片的文件夹。In an embodiment of the present invention, in the above method, the test case is a folder containing several test pictures.
可见,一个包含了若干个测试图片的文件夹就是一个测试用例。现有技术中一些UI自动化测试的实现如下:将测试图片集中保存,在另外一个文件(例如Excel文档)中写入测试图片及相应的测试逻辑。这种情况下,一般将文件称之为测试用例,而测试图片仅作为测试中使用的测试数据,这样就形成了松耦合。但是在测试结果查看以及测试用例、测试数据的管理上就十分不便,例如,发现某个控件的测试没有成功,还需要打开文件,确定相应的测试图片,再打开测试图片,步骤十分繁琐。而在本实施例中,则是直接将包含测试图片的文件夹作为测试用例,在测试结果反查时,可以直接定位到相应的测试图片,并通过测试图片文件名快速了解测试的基本逻辑,直观简单。It can be seen that a folder containing several test images is a test case. Some UI automation tests in the prior art are implemented as follows: save the test pictures in a centralized manner, and write the test pictures and corresponding test logic in another file (for example, an Excel document). In this case, the file is generally called a test case, and the test image is only used as the test data used in the test, thus forming loose coupling. However, it is very inconvenient to view test results and manage test cases and test data. For example, if the test of a certain control is found to be unsuccessful, it is necessary to open the file, determine the corresponding test image, and then open the test image. The steps are very cumbersome. In this embodiment, the folder containing the test image is directly used as the test case. When the test result is reversely checked, the corresponding test image can be directly located, and the basic logic of the test can be quickly understood through the file name of the test image. Intuitive and simple.
在本发明的一个实施例中,上述方法中,测试图片的文件名中包括测试顺序的序列标识;从测试用例的存储路径下读取测试用例包括:按照序列标识从所述文件夹中读取测试图片,其中,每次读取一个测试图片,并在根据该测试图片完成相应的测试后,读取与测试顺序中下一个序列标识对应的测试图片,或者,根据测试结果确定新的序列标识,读取与新的序列标识对应的测试图片;当文件夹中的与测试顺序中最后一个序列标识对应的测试图片被读取完时结束UI自动化测试,或者,当根据一个测试图片的测试结果确定满足测试结束条件时,结束UI自动化测试。In an embodiment of the present invention, in the above method, the file name of the test image includes the sequence identifier of the test sequence; reading the test case from the storage path of the test case includes: reading from the folder according to the sequence identifier A test picture, wherein one test picture is read each time, and after the corresponding test is completed according to the test picture, the test picture corresponding to the next sequence identifier in the test sequence is read, or a new sequence identifier is determined according to the test result , read the test image corresponding to the new sequence ID; end the UI automation test when the test image corresponding to the last sequence ID in the test sequence in the folder is read, or, when the test result based on a test image When it is determined that the test end condition is met, end the UI automation test.
例如,文件夹下有01、02……10开头的十个测试图片,作为测试顺序的序列标识。则在测试时,先读取01开头的图片,根据其文件名的剩余部分获知测试逻辑,生成相应的测试指令,根据该图片完成测试,然后再读取02开头的图片……直至对10开头的图片测试完毕。这样就完成了针对一个测试用例的测试。For example, there are ten test pictures starting with 01, 02...10 under the folder, which are used as the sequence identifier of the test sequence. Then during the test, first read the picture starting with 01, obtain the test logic according to the rest of its file name, generate the corresponding test command, complete the test according to the picture, and then read the picture starting with 02... until the beginning of 10 The picture test is completed. This completes the test for one test case.
而在一些情况下,有可能根据某些测试图片的不同测试结果执行不同的测试逻辑。例如点击一个控件才能进行跳转,那么当该控件不存在时也需要进行别的测试。则可以在测试图片03失败时,跳转至测试图片08的测试,而不是继续测试图片04的测试。In some cases, it is possible to execute different test logic according to different test results of some test pictures. For example, you can click a control to jump, then when the control does not exist, you need to perform other tests. Then, when the test picture 03 fails, jump to the test of the test picture 08 instead of continuing the test of the test picture 04.
根据测试图片文件名生成的测试指令中还可以包括根据测试结果直接判断为结束测试的指令,例如某个图片没有识别到,则直接结束测试。而上述测试过程同样支持在UI自动化测试过程中出现的干扰场景图片,例如测试图片08可能会被一个悬浮窗(例如系统悬浮窗,而非待测试应用的悬浮窗)遮挡,那么可以在测试图片08之前添加悬浮窗对应的测试图片07,这样虽然实际不需要测试悬浮窗08,但是由于其是一个干扰,也可以对其进行操作,例如点击悬浮窗,其消失后露出与测试图片08对应的控件,这样就可以继续UI自动化测试。这样对测试图片07的执行逻辑就变成点击一下即可,成功点击与否并不影响测试结果的呈现,因为这本来就不是测试目的。The test instruction generated according to the test image file name may also include an instruction to directly determine to end the test according to the test result. For example, if a certain image is not recognized, the test is directly terminated. The above test process also supports the interfering scene pictures that appear in the UI automation test process. For example, the test picture 08 may be blocked by a floating window (such as the system floating window, not the floating window of the application to be tested). Add the test picture 07 corresponding to the suspension window before 08, so that although the test suspension window 08 is not actually required, but because it is an interference, it can also be operated, for example, click the suspension window, and after it disappears, the corresponding test picture 08 is exposed. controls so that UI automation testing can continue. In this way, the execution logic of the test picture 07 becomes a click, and whether the click is successful or not does not affect the presentation of the test result, because this is not the purpose of the test.
在本发明的一个实施例中,上述方法中,测试图片的文件名中包括若干条测试信息,以及与各测试信息对应的标识;测试信息包括测试指令的伪指令和/或测试用数据。In an embodiment of the present invention, in the above method, the file name of the test image includes several pieces of test information and an identifier corresponding to each test information; the test information includes pseudo-instructions of the test instructions and/or test data.
基于一个测试图片可能存在多个操作,也可能只有一个操作;操作本身可能仅仅是判断某个测试图片对应的控件是否存在,也可能需要对控件进行点击,也有可能控件是一个输入框,需要输入一些测试数据。下面给出了三个文件名的示例:Based on a test image, there may be multiple operations, or there may be only one operation; the operation itself may be only to determine whether the control corresponding to a test image exists, or it may be necessary to click the control, or the control may be an input box, which requires input Some test data. Examples of three filenames are given below:
01_click_key_Enter.png;02_exist.png;03_type_value.png。01_click_key_Enter.png; 02_exist.png; 03_type_value.png.
其中,01开头的测试图片需要先点击(click)控件,判断特征项(key),再执行按回车键的操作(Enter);02开头的测试图片仅需要判断相应的图片内容是否存在;03开头的测试图片需要在控件中输入(type)相应的测试数据的值(value)。也就是一个测试图片支持多个测试指令。Among them, the test pictures starting with 01 need to click on the control first, judge the feature item (key), and then perform the operation of pressing the Enter key (Enter); the test pictures starting with 02 only need to judge whether the corresponding picture content exists; 03 The test picture at the beginning needs to enter (type) the value of the corresponding test data in the control. That is, a test image supports multiple test instructions.
可以看出,文件名中有多个测试信息,以“_”即下划线分隔开来。当然在其他实施例中可以采用其他标识符号来标识各测试信息。It can be seen that there are multiple test information in the file name, which are separated by "_" or underscore. Of course, in other embodiments, other identification symbols may be used to identify each test information.
同样地,可以看出测试可能包括多个步骤,这也存在着先后顺序。在本发明的一个实施例中,上述方法中,根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令包括:将测试图片的文件名读取为字符串,依序遍历字符串,获得各标识及与各标识对应的测试信息;根据测试信息中的伪指令查找测试指令映射表,查找出相应的测试指令。Likewise, it can be seen that testing may include multiple steps, which also exist in a sequence. In an embodiment of the present invention, in the above method, according to the file name of each test picture in the test case, generating the test instruction corresponding to each test picture includes: reading the file name of the test picture as a character string, and traversing sequentially character string to obtain each identifier and test information corresponding to each identifier; search the test instruction mapping table according to the pseudo-instruction in the test information, and find out the corresponding test instruction.
显然,click是一个可以被测试人员理解的伪指令,而不是一个实际的测试指令。在本实施例中可以预置一个测试指令映射表,设置伪指令和测试指令的映射关系,这样就需要测试图片在命名时也依赖该测试指令映射表进行设置。Obviously, click is a pseudo-instruction that can be understood by the tester, not an actual test instruction. In this embodiment, a test instruction mapping table may be preset to set the mapping relationship between the pseudo-instruction and the test instruction, so that the test image needs to be set by relying on the test instruction mapping table when naming.
具体来说,在本发明的一个实施例中,上述方法中,测试指令包括如下的一种或多种:触发用户事件的指令,判断指令,跳转指令,测试时间设置指令。Specifically, in an embodiment of the present invention, in the above method, the test instruction includes one or more of the following: an instruction to trigger a user event, a judgment instruction, a jump instruction, and a test time setting instruction.
例如,click对应于点击屏幕的操作,Enter对应于按回车键的操作,这些都是触发相应的用户事件,相应的测试指令属于判断指令;而exist属于判断图片是否存在,相应的测试指令属于判断指令;在测试图片不存在时,不按原顺序而是跳转测试其他的测试图片,相应的测试指令属于跳转指令,实际上容易想到对应于代码中if else语句的逻辑;在UI界面中查找图片可能因为各种原因,响应时间不同,因此还可以设置测试时间,以满足部分因测试环境等原因请求响应较慢的等待,相应的测试指令为测试时间设置指令。For example, click corresponds to the operation of clicking the screen, and Enter corresponds to the operation of pressing the Enter key. These are the corresponding user events that trigger the corresponding test instructions, and the corresponding test instructions belong to the judgment instructions; and exist is to judge whether the picture exists, and the corresponding test instructions belong to Judgment instruction; when the test image does not exist, jump to test other test images instead of the original order. The corresponding test instruction belongs to the jump instruction. In fact, it is easy to think of the logic corresponding to the if else statement in the code; in the UI interface The response time may be different for various reasons. Therefore, the test time can also be set to meet the request of slow response due to some reasons such as the test environment. The corresponding test command is the test time setting command.
在本发明的一个实施例中,上述方法中,根据测试指令和相应的测试图片完成UI自动化测试包括:对应用的UI进行截图,在截图中进行测试图片的识别;根据图像识别结果和测试指令完成UI自动化测试。In an embodiment of the present invention, in the above method, completing the UI automation test according to the test instruction and the corresponding test picture includes: taking a screenshot of the UI of the application, and identifying the test picture in the screenshot; according to the image recognition result and the test instruction Complete UI automation testing.
在本实施例中基于图像识别技术,对UI的截图进行识别,判断截图中是否包含了测试图片的图片内容,后续的测试可以参照前述实施例中给出的几种测试逻辑的示例,例如点击控件或是输入测试数据等等。In this embodiment, based on the image recognition technology, the screenshot of the UI is identified, and it is judged whether the screenshot contains the picture content of the test picture. For subsequent tests, refer to the examples of several test logics given in the previous embodiment, such as clicking Controls or input test data, etc.
其中,基于一个测试图片,有可能从截图中识别出多个相同的部分,例如UI界面中有两个“确认”对应的图片,完全一致。在本发明的实施例中可以支持对这类相同的图片全部进行识别和进行相应的操作,例如点击,而在测试用例中仅需要放置一幅图片,仅修改文件名中相应的测试信息即可,例如标注出可能识别出两幅相同的图片,对这两个图片均进行点击操作。Among them, based on a test picture, it is possible to identify multiple identical parts from the screenshot, for example, there are two pictures corresponding to "confirm" in the UI interface, which are completely consistent. In the embodiment of the present invention, all the same pictures can be recognized and corresponding operations can be performed, such as clicking, and only one picture needs to be placed in the test case, and only the corresponding test information in the file name can be modified. , for example, marking that two identical pictures may be identified, and clicking on both pictures.
在本发明的一个实施例中,上述方法还包括:将UI自动化测试的测试结果和对应的测试用例保存至同一目录下。In an embodiment of the present invention, the above method further includes: saving the test result of the UI automation test and the corresponding test case in the same directory.
这样就实现了测试结果的快速排查,能够看到测试结果,就马上可以找到测试用例,找到相应的测试图片,极大地方便了测试人员的排查,提升了测试效率。In this way, the rapid investigation of test results is realized. If you can see the test results, you can immediately find test cases and corresponding test pictures, which greatly facilitates the inspection of testers and improves the test efficiency.
图2示出了根据本发明一个实施例的一种用户界面UI自动化测试的装置的结构示意图。如图2所示,用户界面UI自动化测试的装置200包括:FIG. 2 shows a schematic structural diagram of an apparatus for automatic testing of user interface UI according to an embodiment of the present invention. As shown in FIG. 2, the
测试用例读取单元210,适于从测试用例的存储路径下读取测试用例。The test
测试用例的含义通常要结合使用场景来分析,在本发明的实施例中,自动化测试代码是与测试用例分离的,但测试用例中也包含了测试逻辑。也就是说,测试用例包含有测试所使用的数据,以及测试逻辑的描述信息,但是不包含具体的执行指令。The meaning of the test case is usually analyzed in combination with the usage scenario. In the embodiment of the present invention, the automated test code is separated from the test case, but the test case also includes test logic. That is to say, the test case contains the data used by the test and the description information of the test logic, but does not contain specific execution instructions.
测试指令生成单元220,适于根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令。The test
可以看出,文件名中包含有测试逻辑的描述信息,例如一个测试图片的图片内容描述了应用中的一个控件,文件名中描述了要对这个控件进行点击操作,那么测试指令就是根据这些来生成的。It can be seen that the file name contains description information of the test logic. For example, the image content of a test image describes a control in the application, and the file name describes the click operation on this control, then the test instruction is based on these Generated.
测试单元230,适于根据测试指令和相应的测试图片完成UI自动化测试。The
可见,图2所示的装置,通过各单元的相互配合,从测试用例的存储路径下读取测试用例,根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令,根据测试指令和相应的测试图片完成UI自动化测试。该技术方案基于对测试图片文件名的修改,实现了测试用例与测试图片的紧耦合,便于管理和测试结果排查,同时自动化测试的代码也可以按规律自动生成,方便使用。It can be seen that the device shown in Figure 2, through the cooperation of each unit, reads the test case from the storage path of the test case, and generates the test instruction corresponding to each test image according to the file name of each test image in the test case. Test instructions and corresponding test images complete UI automation testing. Based on the modification of the test image file name, the technical solution realizes the tight coupling between the test case and the test image, which is convenient for management and test result investigation, and at the same time, the code of the automated test can also be automatically generated according to the rules, which is convenient to use.
在本发明的一个实施例中,上述装置中,测试用例为包含若干个测试图片的文件夹。In an embodiment of the present invention, in the above device, the test case is a folder containing several test pictures.
可见,一个包含了若干个测试图片的文件夹就是一个测试用例。现有技术中一些UI自动化测试的实现如下:将测试图片集中保存,在另外一个文件(例如Excel文档)中写入测试图片及相应的测试逻辑。这种情况下,一般将文件称之为测试用例,而测试图片仅作为测试中使用的测试数据,这样就形成了松耦合。但是在测试结果查看以及测试用例、测试数据的管理上就十分不便,例如,发现某个控件的测试没有成功,还需要打开文件,确定相应的测试图片,再打开测试图片,步骤十分繁琐。而在本实施例中,则是直接将包含测试图片的文件夹作为测试用例,在测试结果反查时,可以直接定位到相应的测试图片,并通过测试图片文件名快速了解测试的基本逻辑,直观简单。It can be seen that a folder containing several test images is a test case. Some UI automation tests in the prior art are implemented as follows: save the test pictures in a centralized manner, and write the test pictures and corresponding test logic in another file (for example, an Excel document). In this case, the file is generally called a test case, and the test image is only used as the test data used in the test, thus forming loose coupling. However, it is very inconvenient to view test results and manage test cases and test data. For example, if the test of a certain control is found to be unsuccessful, it is necessary to open the file, determine the corresponding test image, and then open the test image. The steps are very cumbersome. In this embodiment, the folder containing the test image is directly used as the test case. When the test result is reversely checked, the corresponding test image can be directly located, and the basic logic of the test can be quickly understood through the file name of the test image. Intuitive and simple.
在本发明的一个实施例中,上述装置中,测试图片的文件名中包括测试顺序的序列标识;测试用例读取单元210,适于按照序列标识从所述文件夹中读取测试图片,其中,每次读取一个测试图片,并在根据该测试图片完成相应的测试后,读取与测试顺序中下一个序列标识对应的测试图片,或者,根据测试结果确定新的序列标识,读取与新的序列标识对应的测试图片;当文件夹中的与测试顺序中最后一个序列标识对应的测试图片被读取完时结束UI自动化测试,或者,当根据一个测试图片的测试结果确定满足测试结束条件时,结束UI自动化测试。In an embodiment of the present invention, in the above device, the file name of the test picture includes the sequence identifier of the test sequence; the test
例如,文件夹下有01、02……10开头的十个测试图片,作为测试顺序的序列标识。则在测试时,先读取01开头的图片,根据其文件名的剩余部分获知测试逻辑,生成相应的测试指令,根据该图片完成测试,然后再读取02开头的图片……直至对10开头的图片测试完毕。这样就完成了针对一个测试用例的测试。For example, there are ten test pictures starting with 01, 02...10 under the folder, which are used as the sequence identifier of the test sequence. Then during the test, first read the picture starting with 01, obtain the test logic according to the rest of its file name, generate the corresponding test command, complete the test according to the picture, and then read the picture starting with 02... until the beginning of 10 The picture test is completed. This completes the test for one test case.
而在一些情况下,有可能根据某些测试图片的不同测试结果执行不同的测试逻辑。例如点击一个控件才能进行跳转,那么当该控件不存在时也需要进行别的测试。则可以在测试图片03失败时,跳转至测试图片08的测试,而不是继续测试图片04的测试。In some cases, it is possible to execute different test logic according to different test results of some test images. For example, you can click a control to jump, then when the control does not exist, you need to perform other tests. Then, when the test picture 03 fails, jump to the test of the test picture 08 instead of continuing the test of the test picture 04.
根据测试图片文件名生成的测试指令中还可以包括根据测试结果直接判断为结束测试的指令,例如某个图片没有识别到,则直接结束测试。而上述测试过程同样支持在UI自动化测试过程中出现的干扰场景图片,例如测试图片08可能会被一个悬浮窗(例如系统悬浮窗,而非待测试应用的悬浮窗)遮挡,那么可以在测试图片08之前添加悬浮窗对应的测试图片07,这样虽然实际不需要测试悬浮窗08,但是由于其是一个干扰,也可以对其进行操作,例如点击悬浮窗,其消失后露出与测试图片08对应的控件,这样就可以继续UI自动化测试。这样对测试图片07的执行逻辑就变成点击一下即可,成功点击与否并不影响测试结果的呈现,因为这本来就不是测试目的。The test instruction generated according to the test image file name may also include an instruction to directly determine to end the test according to the test result. For example, if a certain image is not recognized, the test is directly terminated. The above test process also supports the interfering scene pictures that appear in the UI automation test process. For example, the test picture 08 may be blocked by a floating window (such as the system floating window, not the floating window of the application to be tested). Add the test picture 07 corresponding to the suspension window before 08, so that although the test suspension window 08 is not actually required, but because it is an interference, it can also be operated, for example, click the suspension window, and after it disappears, the corresponding test picture 08 is exposed. controls so that UI automation testing can continue. In this way, the execution logic of the test picture 07 becomes a click, and whether the click is successful or not does not affect the presentation of the test result, because this is not the purpose of the test.
在本发明的一个实施例中,上述装置中,测试图片的文件名中包括若干条测试信息,以及与各测试信息对应的标识;测试信息包括测试指令的伪指令和/或测试用数据。In an embodiment of the present invention, in the above device, the file name of the test image includes several pieces of test information and an identifier corresponding to each test information; the test information includes pseudo-instructions of the test instructions and/or test data.
基于一个测试图片可能存在多个操作,也可能只有一个操作;操作本身可能仅仅是判断某个测试图片对应的控件是否存在,也可能需要对控件进行点击,也有可能控件是一个输入框,需要输入一些测试数据。下面给出了三个文件名的示例:Based on a test image, there may be multiple operations, or there may be only one operation; the operation itself may be only to determine whether the control corresponding to a test image exists, or it may be necessary to click the control, or the control may be an input box, which requires input Some test data. Examples of three filenames are given below:
01_click_key_Enter.png;02_exist.png;03_type_value.png。01_click_key_Enter.png; 02_exist.png; 03_type_value.png.
其中,01开头的测试图片需要先点击(click)控件,判断特征项(key),再执行按回车键的操作(Enter);02开头的测试图片仅需要判断相应的图片内容是否存在;03开头的测试图片需要在控件中输入(type)相应的测试数据的值(value)。也就是一个测试图片支持多个测试指令。Among them, the test pictures starting with 01 need to click on the control first, judge the feature item (key), and then perform the operation of pressing the Enter key (Enter); the test pictures starting with 02 only need to judge whether the corresponding picture content exists; 03 The test picture at the beginning needs to enter (type) the value of the corresponding test data in the control. That is, a test image supports multiple test instructions.
可以看出,文件名中有多个测试信息,以“_”即下划线分隔开来。当然在其他实施例中可以采用其他标识符号来标识各测试信息。It can be seen that there are multiple test information in the file name, which are separated by "_" or underscore. Of course, in other embodiments, other identification symbols may be used to identify each test information.
同样地,可以看出测试可能包括多个步骤,这也存在着先后顺序。在本发明的一个实施例中,上述装置中,测试指令生成单元220,适于将测试图片的文件名读取为字符串,依序遍历字符串,获得各标识及与各标识对应的测试信息;根据测试信息中的伪指令查找测试指令映射表,查找出相应的测试指令。Likewise, it can be seen that testing may include multiple steps, which also exist in a sequence. In an embodiment of the present invention, in the above device, the test
显然,click是一个可以被测试人员理解的伪指令,而不是一个实际的测试指令。在本实施例中可以预置一个测试指令映射表,设置伪指令和测试指令的映射关系,这样就需要测试图片在命名时也依赖该测试指令映射表进行设置。Obviously, click is a pseudo-instruction that can be understood by the tester, not an actual test instruction. In this embodiment, a test instruction mapping table may be preset to set the mapping relationship between the pseudo-instruction and the test instruction, so that the test image needs to be set by relying on the test instruction mapping table when naming.
具体来说,在本发明的一个实施例中,上述装置中,测试指令包括如下的一种或多种:触发用户事件的指令,判断指令,跳转指令,测试时间设置指令。Specifically, in an embodiment of the present invention, in the above device, the test instruction includes one or more of the following: an instruction to trigger a user event, a judgment instruction, a jump instruction, and a test time setting instruction.
例如,click对应于点击屏幕的操作,Enter对应于按回车键的操作,这些都是触发相应的用户事件,相应的测试指令属于判断指令;而exist属于判断图片是否存在,相应的测试指令属于判断指令;在测试图片不存在时,不按原顺序而是跳转测试其他的测试图片,相应的测试指令属于跳转指令,实际上容易想到对应于代码中if else语句的逻辑;在UI界面中查找图片可能因为各种原因,响应时间不同,因此还可以设置测试时间,以满足部分因测试环境等原因请求响应较慢的等待,相应的测试指令为测试时间设置指令。For example, click corresponds to the operation of clicking the screen, and Enter corresponds to the operation of pressing the Enter key. These are the corresponding user events that trigger the corresponding test instructions, and the corresponding test instructions belong to the judgment instructions; and exist is to judge whether the picture exists, and the corresponding test instructions belong to Judgment instruction; when the test image does not exist, jump to test other test images instead of the original order. The corresponding test instruction belongs to the jump instruction. In fact, it is easy to think of the logic corresponding to the if else statement in the code; in the UI interface The response time may be different for various reasons. Therefore, the test time can also be set to meet the request of slow response due to some reasons such as the test environment. The corresponding test command is the test time setting command.
在本发明的一个实施例中,上述装置中,测试单元230,适于对应用的UI进行截图,在截图中进行测试图片的识别;根据图像识别结果和测试指令完成UI自动化测试。In an embodiment of the present invention, in the above device, the
在本实施例中基于图像识别技术,对UI的截图进行识别,判断截图中是否包含了测试图片的图片内容,后续的测试可以参照前述实施例中给出的几种测试逻辑的示例,例如点击控件或是输入测试数据等等。In this embodiment, based on the image recognition technology, the screenshot of the UI is identified, and it is judged whether the screenshot contains the picture content of the test picture. For subsequent tests, refer to the examples of several test logics given in the previous embodiment, such as clicking Controls or input test data, etc.
其中,基于一个测试图片,有可能从截图中识别出多个相同的部分,例如UI界面中有两个“确认”对应的图片,完全一致。在本发明的实施例中可以支持对这类相同的图片全部进行识别和进行相应的操作,例如点击,而在测试用例中仅需要放置一幅图片,仅修改文件名中相应的测试信息即可,例如标注出可能识别出两幅相同的图片,对这两个图片均进行点击操作。Among them, based on a test picture, it is possible to identify multiple identical parts from the screenshot, for example, there are two pictures corresponding to "confirm" in the UI interface, which are completely consistent. In the embodiment of the present invention, all the same pictures can be recognized and corresponding operations can be performed, such as clicking, and only one picture needs to be placed in the test case, and only the corresponding test information in the file name can be modified. , for example, marking that two identical pictures may be identified, and clicking on both pictures.
在本发明的一个实施例中,上述装置中,测试单元230,还适于将UI自动化测试的测试结果和对应的测试用例保存至同一目录下。In an embodiment of the present invention, in the above-mentioned apparatus, the
这样就实现了测试结果的快速排查,能够看到测试结果,就马上可以找到测试用例,找到相应的测试图片,极大地方便了测试人员的排查,提升了测试效率。In this way, the rapid investigation of test results is realized. If you can see the test results, you can immediately find test cases and corresponding test pictures, which greatly facilitates the inspection of testers and improves the test efficiency.
综上所述,本发明的技术方案,从测试用例的存储路径下读取测试用例,根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令,根据测试指令和相应的测试图片完成UI自动化测试。该技术方案基于对测试图片文件名的修改,实现了测试用例与测试图片的紧耦合,便于管理和测试结果排查,同时自动化测试的代码也可以按规律自动生成,方便使用。To sum up, the technical solution of the present invention reads the test case from the storage path of the test case, generates the test instruction corresponding to each test image according to the file name of each test image in the test case, and generates the test instruction corresponding to each test image according to the test instruction and the corresponding test case. The test image completes the UI automation test. Based on the modification of the test image file name, the technical solution realizes the tight coupling between the test case and the test image, which is convenient for management and test result investigation, and at the same time, the code of the automated test can also be automatically generated according to the rules, which is convenient to use.
需要说明的是:It should be noted:
在此提供的算法和显示不与任何特定计算机、虚拟装置或者其它设备固有相关。各种通用装置也可以与基于在此的示教一起使用。根据上面的描述,构造这类装置所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays provided herein are not inherently related to any particular computer, virtual appliance, or other device. Various general-purpose devices can also be used with the teachings based on this. The structure required to construct such a device is apparent from the above description. Furthermore, the present invention is not directed to any particular programming language. It is to be understood that various programming languages may be used to implement the inventions described herein, and that the descriptions of specific languages above are intended to disclose the best mode for carrying out the invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. It will be understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it is to be understood that in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together into a single embodiment, figure, or its description. This disclosure, however, should not be construed as reflecting an intention that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. The modules or units or components in the embodiments may be combined into one module or unit or component, and further they may be divided into multiple sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method so disclosed may be employed in any combination, unless at least some of such features and/or procedures or elements are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, those skilled in the art will appreciate that although some of the embodiments described herein include certain features, but not others, included in other embodiments, that combinations of features of different embodiments are intended to be within the scope of the invention within and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的用户界面UI自动化测试的装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。Various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components of the apparatus for automatic testing of user interfaces and UIs according to embodiments of the present invention . The present invention can also be implemented as apparatus or apparatus programs (eg, computer programs and computer program products) for performing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from Internet sites, or provided on carrier signals, or in any other form.
例如,图3示出了根据本发明一个实施例的电子设备的结构示意图。该电子设备包括处理器310和被安排成存储计算机可执行指令(计算机可读程序代码)的存储器320。存储器320可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器320具有存储用于执行上述方法中的任何方法步骤的计算机可读程序代码331的存储空间330。例如,用于存储计算机可读程序代码的存储空间330可以包括分别用于实现上面的方法中的各种步骤的各个计算机可读程序代码331。计算机可读程序代码331可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为例如图4所述的计算机可读存储介质。图4示出了根据本发明一个实施例的一种计算机可读存储介质的结构示意图。该计算机可读存储介质400存储有用于执行根据本发明的方法步骤的计算机可读程序代码331,可以被电子设备300的处理器310读取,当计算机可读程序代码331由电子设备300运行时,导致该电子设备300执行上面所描述的方法中的各个步骤,具体来说,该计算机可读存储介质存储的计算机可读程序代码331可以执行上述任一实施例中示出的方法。计算机可读程序代码331可以以适当形式进行压缩。For example, FIG. 3 shows a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic device includes a
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-described embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by those skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. do not denote any order. These words can be interpreted as names.
本发明提供了A1、一种用户界面UI自动化测试的方法,包括:The present invention provides A1, a method for automatic testing of user interface UI, comprising:
从测试用例的存储路径下读取测试用例;Read the test case from the storage path of the test case;
根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令;Generate test instructions corresponding to each test image according to the file name of each test image in the test case;
根据所述测试指令和相应的测试图片完成UI自动化测试。The UI automation test is completed according to the test instruction and the corresponding test picture.
A2、如A1所述的方法,其中,所述测试用例为包含若干个测试图片的文件夹。A2. The method of A1, wherein the test case is a folder containing several test pictures.
A3、如A2所述的方法,其中,所述测试图片的文件名中包括测试顺序的序列标识;A3. The method of A2, wherein the filename of the test picture includes the sequence identifier of the test sequence;
所述从测试用例的存储路径下读取测试用例包括:The reading of the test case from the storage path of the test case includes:
按照序列标识从所述文件夹中读取测试图片,其中,每次读取一个测试图片,并在根据该测试图片完成相应的测试后,读取与测试顺序中下一个序列标识对应的测试图片,或者,根据测试结果确定新的序列标识,读取与新的序列标识对应的测试图片;Read the test pictures from the folder according to the sequence identifier, wherein one test image is read at a time, and after the corresponding test is completed according to the test image, the test image corresponding to the next sequence identifier in the test sequence is read , or, determine a new sequence identification according to the test result, and read the test picture corresponding to the new sequence identification;
当所述文件夹中的与测试顺序中最后一个序列标识对应的测试图片被读取完时结束UI自动化测试,或者,当根据一个测试图片的测试结果确定满足测试结束条件时,结束UI自动化测试。End the UI automation test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read, or, when it is determined according to the test result of a test picture that the test end condition is met, end the UI automation test .
A4、如A1所述的方法,其中,测试图片的文件名中包括若干条测试信息,以及与各测试信息对应的标识;A4, the method as described in A1, wherein, the file name of the test picture includes several pieces of test information, and an identifier corresponding to each test information;
所述测试信息包括测试指令的伪指令和/或测试用数据。The test information includes pseudo-instructions of the test instructions and/or test data.
A5、如A4所述的方法,其中,所述根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令包括:A5. The method according to A4, wherein, according to the file name of each test picture in the test case, generating the test instruction corresponding to each test picture includes:
将测试图片的文件名读取为字符串,依序遍历字符串,获得各标识及与各标识对应的测试信息;Read the file name of the test image as a string, traverse the string in sequence, and obtain each logo and the test information corresponding to each logo;
根据所述测试信息中的伪指令查找测试指令映射表,查找出相应的测试指令。The test instruction mapping table is searched according to the pseudo-instruction in the test information, and the corresponding test instruction is found out.
A6、如A1所述的方法,其中,所述测试指令包括如下的一种或多种:A6. The method of A1, wherein the test instruction includes one or more of the following:
触发用户事件的指令,判断指令,跳转指令,测试时间设置指令。Instructions that trigger user events, judgment instructions, jump instructions, and test time setting instructions.
A7、如A1所述的方法,其中,所述根据所述测试指令和相应的测试图片完成UI自动化测试包括:A7. The method according to A1, wherein the completing the UI automation test according to the test instruction and the corresponding test picture includes:
对应用的UI进行截图,在截图中进行测试图片的识别;Take a screenshot of the UI of the application, and identify the test image in the screenshot;
根据图像识别结果和所述测试指令完成UI自动化测试。The UI automation test is completed according to the image recognition result and the test instruction.
A8、如A1所述的方法,其中,该方法还包括:A8. The method of A1, wherein the method further comprises:
将UI自动化测试的测试结果和对应的测试用例保存至同一目录下。Save the test results of the UI automation test and the corresponding test cases to the same directory.
本发明还提供了B9、一种用户界面UI自动化测试的装置,包括:The present invention also provides B9, a device for automatic testing of user interface UI, comprising:
测试用例读取单元,适于从测试用例的存储路径下读取测试用例;The test case reading unit is suitable for reading the test case from the storage path of the test case;
测试指令生成单元,适于根据测试用例中各测试图片的文件名,生成与各测试图片对应的测试指令;A test instruction generation unit, adapted to generate a test instruction corresponding to each test image according to the file name of each test image in the test case;
测试单元,适于根据所述测试指令和相应的测试图片完成UI自动化测试。The test unit is adapted to complete the UI automation test according to the test instruction and the corresponding test picture.
B10、如B9所述的装置,其中,所述测试用例为包含若干个测试图片的文件夹。B10. The device according to B9, wherein the test case is a folder containing several test pictures.
B11、如B10所述的装置,其中,所述测试图片的文件名中包括测试顺序的序列标识;B11. The device of B10, wherein the file name of the test picture includes a sequence identifier of the test sequence;
所述测试用例读取单元,适于按照序列标识从所述文件夹中读取测试图片,其中,每次读取一个测试图片,并在根据该测试图片完成相应的测试后,读取与测试顺序中下一个序列标识对应的测试图片,或者,根据测试结果确定新的序列标识,读取与新的序列标识对应的测试图片;当所述文件夹中的与测试顺序中最后一个序列标识对应的测试图片被读取完时结束UI自动化测试,或者,当根据一个测试图片的测试结果确定满足测试结束条件时,结束UI自动化测试。The test case reading unit is adapted to read test pictures from the folder according to the sequence identifier, wherein one test picture is read at a time, and after the corresponding test is completed according to the test picture, read and test The test picture corresponding to the next sequence identification in the sequence, or, according to the test result, determine the new sequence identification, and read the test picture corresponding to the new sequence identification; when the last sequence identification in the folder corresponds to the last sequence identification in the test sequence End the UI automation test when the test picture of the test picture is read, or, when it is determined that the test end condition is satisfied according to the test result of a test picture, end the UI automation test.
B12、如B9所述的装置,其中,测试图片的文件名中包括若干条测试信息,以及与各测试信息对应的标识;B12, the device as described in B9, wherein, the file name of the test picture includes several pieces of test information, and a mark corresponding to each test information;
所述测试信息包括测试指令的伪指令和/或测试用数据。The test information includes pseudo-instructions of the test instructions and/or test data.
B13、如B12所述的装置,其中,B13. The device of B12, wherein,
所述测试指令生成单元,适于将测试图片的文件名读取为字符串,依序遍历字符串,获得各标识及与各标识对应的测试信息;根据所述测试信息中的伪指令查找测试指令映射表,查找出相应的测试指令。The test instruction generation unit is adapted to read the file name of the test image as a character string, traverse the character string in sequence, and obtain each mark and test information corresponding to each mark; search for the test according to the pseudo-instruction in the test information The instruction mapping table is used to find out the corresponding test instruction.
B14、如B9所述的装置,其中,所述测试指令包括如下的一种或多种:B14. The device according to B9, wherein the test instruction includes one or more of the following:
触发用户事件的指令,判断指令,跳转指令,测试时间设置指令。Instructions that trigger user events, judgment instructions, jump instructions, and test time setting instructions.
B15、如B9所述的装置,其中,B15. The device of B9, wherein,
所述测试单元,适于对应用的UI进行截图,在截图中进行测试图片的识别;根据图像识别结果和所述测试指令完成UI自动化测试。The test unit is adapted to take a screenshot of the UI of the application, and identify the test picture in the screenshot; complete the UI automation test according to the image recognition result and the test instruction.
B16、如B15所述的装置,其中,B16. The device of B15, wherein,
所述测试单元,还适于将UI自动化测试的测试结果和对应的测试用例保存至同一目录下。The test unit is also suitable for saving the test result of the UI automation test and the corresponding test case in the same directory.
本发明还提供了C17、一种电子设备,其中,该电子设备包括:处理器;以及被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器执行A1-A8中任一项所述的方法。The present invention also provides C17, an electronic device, wherein the electronic device comprises: a processor; and a memory arranged to store computer-executable instructions that, when executed, cause the processor to execute A1 - The method of any one of A8.
本发明还提供了D18、一种计算机可读存储介质,其中,所述计算机可读存储介质存储一个或多个程序,所述一个或多个程序当被处理器执行时,实现如A1-A8中任一项所述的方法。The present invention also provides D18, a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and the one or more programs, when executed by the processor, implement operations such as A1-A8 The method of any of the above.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810789737.4A CN110737573B (en) | 2018-07-18 | 2018-07-18 | Method and device for automatically testing user interface UI |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810789737.4A CN110737573B (en) | 2018-07-18 | 2018-07-18 | Method and device for automatically testing user interface UI |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110737573A true CN110737573A (en) | 2020-01-31 |
CN110737573B CN110737573B (en) | 2023-02-17 |
Family
ID=69235246
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810789737.4A Active CN110737573B (en) | 2018-07-18 | 2018-07-18 | Method and device for automatically testing user interface UI |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110737573B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112150431A (en) * | 2020-09-21 | 2020-12-29 | 京东数字科技控股股份有限公司 | UI visual walkthrough method and device, storage medium and electronic device |
CN114323585A (en) * | 2021-12-28 | 2022-04-12 | 梅卡曼德(北京)机器人科技有限公司 | Method for calculating modulation transfer function in batch, electronic device and storage medium |
WO2022141745A1 (en) * | 2020-12-29 | 2022-07-07 | 福州富昌维控电子科技有限公司 | Ladder diagram-based plc instruction quality detection method, and terminal |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103309797A (en) * | 2012-03-09 | 2013-09-18 | 阿里巴巴集团控股有限公司 | Automatic testing method and device of user interface |
US9075918B1 (en) * | 2014-02-25 | 2015-07-07 | International Business Machines Corporation | System and method for creating change-resilient scripts |
CN107861862A (en) * | 2017-06-27 | 2018-03-30 | 陆金所(上海)科技服务有限公司 | UI automated testing methods, device and computer-readable recording medium |
CN107885665A (en) * | 2017-12-28 | 2018-04-06 | 努比亚技术有限公司 | With case script method of testing, mobile terminal and computer-readable recording medium |
CN107957948A (en) * | 2017-12-07 | 2018-04-24 | 郑州云海信息技术有限公司 | A kind of user interface automatic test device and method |
CN108268373A (en) * | 2017-09-21 | 2018-07-10 | 平安科技(深圳)有限公司 | Automatic test cases management method, device, equipment and storage medium |
-
2018
- 2018-07-18 CN CN201810789737.4A patent/CN110737573B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103309797A (en) * | 2012-03-09 | 2013-09-18 | 阿里巴巴集团控股有限公司 | Automatic testing method and device of user interface |
US9075918B1 (en) * | 2014-02-25 | 2015-07-07 | International Business Machines Corporation | System and method for creating change-resilient scripts |
CN107861862A (en) * | 2017-06-27 | 2018-03-30 | 陆金所(上海)科技服务有限公司 | UI automated testing methods, device and computer-readable recording medium |
CN108268373A (en) * | 2017-09-21 | 2018-07-10 | 平安科技(深圳)有限公司 | Automatic test cases management method, device, equipment and storage medium |
CN107957948A (en) * | 2017-12-07 | 2018-04-24 | 郑州云海信息技术有限公司 | A kind of user interface automatic test device and method |
CN107885665A (en) * | 2017-12-28 | 2018-04-06 | 努比亚技术有限公司 | With case script method of testing, mobile terminal and computer-readable recording medium |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112150431A (en) * | 2020-09-21 | 2020-12-29 | 京东数字科技控股股份有限公司 | UI visual walkthrough method and device, storage medium and electronic device |
WO2022141745A1 (en) * | 2020-12-29 | 2022-07-07 | 福州富昌维控电子科技有限公司 | Ladder diagram-based plc instruction quality detection method, and terminal |
CN114323585A (en) * | 2021-12-28 | 2022-04-12 | 梅卡曼德(北京)机器人科技有限公司 | Method for calculating modulation transfer function in batch, electronic device and storage medium |
CN114323585B (en) * | 2021-12-28 | 2024-04-12 | 梅卡曼德(北京)机器人科技有限公司 | Method for batch calculation of modulation transfer function, electronic device and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110737573B (en) | 2023-02-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9619211B2 (en) | Code suggestion in a software development tool | |
US9672029B2 (en) | Determining test case priorities based on tagged execution paths | |
US9619373B2 (en) | Method and apparatus to semantically connect independent build and test processes | |
CN111796831B (en) | Compiling method and device for multi-chip compatibility | |
CN111831564A (en) | A regression testing method, device and computing device | |
CN105190548A (en) | Automatic risk analysis of software | |
CN110554962A (en) | Regression testing process covering method, server and computer readable storage medium | |
CN110737573B (en) | Method and device for automatically testing user interface UI | |
CN105389262A (en) | Method and device for generating test suggestions in allusion to interface tests | |
CN110287696A (en) | A kind of detection method, device and the equipment of the shell process that rebounds | |
CN105743736A (en) | Automated testing method and system | |
CN117408193B (en) | Virtuoso-based instance call information extraction method | |
EP2951680B1 (en) | Acquiring identification of an application lifecycle management entity associated with similar code | |
CN108829389A (en) | Android application automation triggering execution method based on Appium | |
US20130339798A1 (en) | Methods for automated software testing and devices thereof | |
CN110750434A (en) | Interface testing method, apparatus, electronic device, and computer-readable storage medium | |
CN105512276A (en) | Method and device for constructing junk file and electronic equipment | |
CN110737577B (en) | A method and device for storing test defect data | |
RU2011144841A (en) | CAPTURE AND LOADING OF OPERATING SYSTEM STATES | |
CN113326193A (en) | Applet testing method and device | |
US9063723B2 (en) | Function-based software comparison method | |
CN112181809B (en) | A graphical user interface automated testing method based on multiple positioning methods | |
CN114880231A (en) | Debugging method, debugging device and computing device for application program control | |
CN110209593B (en) | A preference-oriented Android application testing method | |
CN113591147A (en) | Data extraction method and device, computer equipment and 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 |