Automated testing method and system for Android applications and storage medium
By dividing the display screen of the Android application into click blocks, generating a click position matrix, and comparing the page screenshot to determine the effective click event, forming an effective click chain, it solves the problem that it is difficult to effectively conduct automated testing of Android game applications in the existing technology, and realizes the Complete functional testing and page traversal of complex applications.
Patent Information
- Application Number
- CN202111560629.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2041-12-20
AI Technical Summary
It is difficult to effectively conduct automated testing of Android game applications in the existing technology, especially to effectively trigger the complete functions of complex applications and traverse all application pages.
By dividing the display screen of the test device into N click blocks, a click position matrix is generated, and clicking the click blocks in a predetermined order, triggering a page screenshot comparison of jump to the corresponding activity, determining the valid click event, and storing it to the test An effective click chain is formed in the use case library.
It realizes automated testing of Android applications developed using third-party game engines, especially applications that can assist in the switching without Activity and cannot directly obtain page controls, which improves the efficiency and versatility of the test.
Smart Images

Figure CN114238119B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of network technology and security, and more specifically to automated testing of Android applications. Background Art
[0002] With the rapid development of Internet technology, many game applications have been developed for people's entertainment. However, most of the current game applications are developed by using game engines (such as Unity3D, Cocos2D, UE, etc.). Therefore, when performing functional testing on the developed game applications, a large number of automated testing frameworks based on Android native control recognition technology based on UI Automator on the market cannot play a role. Moreover, since the pages of game applications are rendered by the engine and presented on the page, there is often only one main activity in the manifest file, making it impossible to traverse all application pages by obtaining the Activity tag in the manifest file.
[0003] To this end, some solutions have been explored in the prior art, but there are still shortcomings. Monkey-based automated testing can only randomly generate a large number of simulated mobile phone operations, and it is difficult to trigger the complete functions of executing complex applications. The page controls are exposed based on system / application instrumentation or embedding third-party controls, and then the application functions are traversed by forming a control stack. There are high barriers to use and the need to obtain code to implement white box testing. Automated testing based on recording and playback has the problem of low versatility, which is similar to writing test cases by yourself.
[0004] In order to overcome the above defects, it is necessary to provide an innovative automated testing method and system for Android applications. Summary of the invention
[0005] A brief overview of the disclosure is given below in order to provide a basic understanding of some aspects of the disclosure. However, it should be understood that this overview is not an exhaustive overview of the disclosure. It is not intended to identify the key or important parts of the disclosure, nor is it intended to limit the scope of the disclosure. Its purpose is simply to give some concepts of the disclosure in a simplified form as a prelude to a more detailed description given later.
[0006] According to one aspect of the present disclosure, there is provided an automated testing method for Android applications, comprising: dividing a display screen of a test device into N click blocks, wherein N is an integer greater than 1, and generating a click position matrix from elements including click position coordinate information corresponding to each click block; obtaining an initial startup activity Activity and starting an application APP, and storing a current page screenshot; clicking the N click blocks on the display screen in a predetermined order to trigger a click event, and storing a page screenshot of the Activity to which the click jumps; comparing the page screenshot before the click with the page screenshot obtained after the click to determine the similarity between the two; if it is determined that the similarity is less than a predetermined threshold, storing the position coordinate information of the element in the click position matrix corresponding to the current click in a test case library; and if it is determined that the clicks on the N click blocks have been completed or a page screenshot that meets the click termination condition has been detected, aggregating the position coordinate information stored in the test case library to form a valid click chain, wherein each position coordinate information in the valid click chain corresponds to an Activity of the tested application.
[0007] According to a second aspect of the present disclosure, there is provided an automated testing system for Android applications, comprising a click position matrix generating unit, for dividing a display screen of a test device into N click blocks, wherein N is an integer greater than 1, and generating a click position matrix based on elements including click position coordinate information corresponding to each click block; a click event triggering unit, for triggering a jump to an activity corresponding to the click position coordinate information of the click block by clicking the click blocks divided on the display screen in sequence; a storage unit, for storing the click position coordinate information of each click block of the display screen and a page screenshot of the Activity jumped to after the click; a comparison unit, for comparing the page screenshot before the click and the page screenshot obtained after the click to determine the similarity between the two, and comparing the similarity with a predetermined threshold, and determining that the current click event is a valid click event when the similarity is lower than the predetermined threshold; and a test case library, for storing the position coordinate information of the elements in the click position matrix corresponding to each valid click event, and forming a valid click chain, wherein each position coordinate information of the valid click chain corresponds to an Activity of the application under test.
[0008] According to another aspect of the present disclosure, a computer-readable storage medium is provided, which includes computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the one or more processors execute the method according to the above aspects of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0010] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0011] Figure 1 An overall schematic diagram of an automated testing system for Android applications according to an embodiment of the present disclosure is shown;
[0012] Figure 2 A flowchart of an automated testing method for Android applications according to an embodiment of the present disclosure is shown; and
[0013] Figure 3 An exemplary configuration of a computing device that can implement an embodiment according to the present disclosure is shown. DETAILED DESCRIPTION
[0014] Figure 1 A schematic block diagram of an automated testing system 100 for Android applications according to an embodiment of the present disclosure is shown. The system 100 includes a click position matrix generating unit 101, a click event triggering unit 102, a storage unit 103, a comparison unit 104 and a test case library 105.
[0015] The click position matrix generating unit 101 is used to divide the display screen into N click blocks (N is an integer greater than 1) according to the length and width of the display screen of the test device according to a predetermined number of pixels, and to generate a click position matrix based on elements including click position coordinate information corresponding to each click block.
[0016] The click event triggering unit 102 is used to trigger jumping to the Activity corresponding to the click position coordinate information of the click block by clicking the click blocks divided on the display screen in sequence.
[0017] The storage unit 103 is used to store the click position coordinate information of each click block on the display screen and the page screenshot of the Activity jumped to after the click.
[0018] The comparison unit 104 is used to compare the page screenshot before the click with the page screenshot obtained after the click using image recognition technology to determine the similarity between the two, and compare the similarity with a predetermined threshold. If the similarity is lower than the predetermined threshold, the current click event is determined to be a valid click event.
[0019] The test case library 105 is used to store the position coordinate information of the elements in the click position matrix corresponding to each valid click event, and form a valid click chain, each position coordinate information of the valid click chain corresponds to an Activity of the tested application.
[0020] Reference now Figure 2 A flowchart describing an automated testing method for Android applications according to an embodiment of the present disclosure is provided.
[0021] After the game application is developed or partially modified, it is necessary to perform functional testing on the game application.
[0022] When testing, first determine whether the Android application package (APK) is a native Android application package. Specifically, traverse the APK directory name and file name, and query keywords such as unity, cocos, ue4, etc. to determine whether the APK is a native Android application.
[0023] When it is determined that the Android application package APK is a native Android application package, it can be tested using a common control identification test method.
[0024] In the case where it is determined that the Android application package APK is a non-native Android application package, the automated testing method for Android applications disclosed in the present invention is used to perform testing.
[0025] First, in step S201, the display screen of the test device is divided into N click blocks, and a click position matrix is generated by elements including click position coordinate information corresponding to each click block.
[0026] Specifically, a real machine / simulator device for automated testing is initialized, the length and width of the display screen of the test device are obtained, and the display screen is divided into N click blocks (N is an integer greater than 1) according to the length and width of the display screen according to a predetermined number of pixels, and each click block has corresponding click position coordinate information. A click position matrix is generated so that each matrix element includes click position coordinate information corresponding to each click block. The click position matrix is stored in a storage unit.
[0027] According to an embodiment of the present disclosure, the display screen may be equally divided according to a predetermined number of pixels based on the length and width of the display screen, so that the length and width of each click block and the number of pixels contained therein are equal to generate a click position matrix.
[0028] Alternatively, the display screen may be divided in any appropriate manner according to the length and width dimensions of the display screen and the number of pixels to generate the click position matrix.
[0029] Assume that the click position matrix has elements x with m rows and n columns, 1≤m≤N, 1≤n≤N, and m×n=N.
[0030] Next, in step S202, the APK package name and the initial startup activity (Activity) are obtained, and the application (APP) is started.
[0031] In step S203, the current page screenshot is stored in a storage unit.
[0032] In step S204, N click blocks on the display screen are clicked in a predetermined order to trigger a click event, and a screenshot of the page of the Activity jumped to after the click is stored.
[0033] According to an embodiment of the present disclosure, the elements of the click position matrix are arranged in a predetermined order, for example, from the element in the 1st row and the 1st column to the element in the mth row and the nth column, that is, x 1,1 , x 1,2 , …, x 1,n , x 2,1 , x 2,2 , …, x 2,n , …, x m,1 , x m,2 , …, x m,n , starting from the first click block corresponding to the element in the first row and first column, click the click blocks corresponding to the elements of the click position matrix on the display screen in sequence to trigger a click event, so that a page screenshot of the Activity to which the click jumps is presented on the display screen. The page screenshot of the Activity to which the click jumps is stored in a storage unit.
[0034] According to an embodiment of the present disclosure, in the process of performing automated testing on an application, conditions for terminating clicks and terminating the test can be pre-set. When it is detected through image recognition technology that the screenshot of the page of the Activity jumped to by clicking includes keywords associated with the pre-set conditions for terminating clicks, stop clicking and end the test. For example, if the test requires that the test be ended after accessing the login / registration page, then in the process of traversing the Activity by clicking on each click block on the display screen, if keywords associated with the conditions for terminating clicks, such as "login", "user name", and "password", are identified in the page screenshot through image recognition technology, the click is terminated and the test is ended.
[0035] If the condition for terminating the click and ending the test is not set, N click blocks corresponding to the elements in the click position matrix are automatically clicked in a predetermined order to traverse all activities.
[0036] In step S205, the screenshot of the page before the click and the screenshot of the page obtained after the click are compared using image recognition technology to determine the similarity between the two. Specifically, the image features of the screenshot of the page before the click and the screenshot of the page obtained after the click stored in the storage unit are respectively extracted through image recognition technology for comparison.
[0037] In step S206, it is determined whether the similarity is greater than a predetermined threshold. If the similarity is greater than the predetermined threshold, it indicates that the similarity between the screenshots of the page before and after the click is high, and it is determined that the current click event is invalid. Then, return to step S204 to continue clicking the next click block k (k is an integer, 1 < k ≤ N), and step S205 is executed again.
[0038] If it is determined in step S206 that the similarity is less than the predetermined threshold, it indicates that the similarity between the screenshots of the page before and after the click is not high, and it is determined that the current click event is valid. Then, in step S207, the position coordinate information of the elements in the click position matrix corresponding to the current click is stored in the test case library.
[0039] Then, in step S208, it is determined whether the clicking of the N click blocks has been completed, that is, it is determined whether k is equal to N, or it is determined whether a page screenshot that meets the termination click condition has been detected.
[0040] If it is determined that the clicking of the N click blocks has not been completed, that is, k < N, and a page screenshot that meets the termination click condition has not been detected, then return to step S203, and steps S204, S205, S206, and S207 are executed again.
[0041] If it is determined that the clicking of the N click blocks has been completed or a page screenshot that meets the termination click condition has been detected, then stop the continuous clicking operation. In step S209, the position coordinate information stored in the test case library corresponding to the valid click events is collected to form a valid click chain, and each position coordinate information of the valid click chain corresponds to an Activity of the application under test.
[0042] Using the test case library constructed in this way, by automatically clicking on the corresponding click blocks on the display screen according to the valid click chain, it is possible to automatically traverse the Activities of the same or similar applications. Moreover, the test case library can be reused repeatedly to save the test time of repeated tests.
[0043] In addition, according to the correspondence between the click blocks on the display screen and the corresponding Activities, the click coordinate positions can be located on the display screen for a specified Activity. When only the specified Activity needs to be tested, the test can be performed by clicking on the corresponding click coordinate positions, so as to achieve the rapid testing of the specified Activity.
[0044] According to the system and method for automated testing of Android applications disclosed in the present invention, automated testing can be performed on Android applications developed using a third-party game engine, and in particular, can assist in automated testing of applications that do not have Activity switching and cannot directly obtain page controls.
[0045] Figure 3 An exemplary configuration of a computing device 300 capable of implementing an embodiment according to the present disclosure is shown.
[0046] The computing device 300 is an example of a hardware device to which the above aspects of the present disclosure can be applied. The computing device 300 can be any machine configured to perform processing and / or calculations. The computing device 300 can be, but is not limited to, a tablet computer, a personal data assistant (PDA), a smart phone, a car computer, or a combination thereof.
[0047] like Figure 3 As shown, computing device 300 may include one or more components that may be connected or communicated with bus 302 via one or more interfaces. Bus 302 may include, but is not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus, etc. Computing device 300 may include, for example, one or more processors 304, one or more input devices 306, and one or more output devices 308. One or more processors 304 may be any type of processor, and may include, but is not limited to, one or more general-purpose processors or special-purpose processors (such as special-purpose processing chips). Processor 302 may correspond to, for example, Figure 1 The units of the automated testing system for Android applications in the embodiment of the present invention. The input device 306 can be any type of input device capable of inputting information to the computing device, and can include but is not limited to a mouse, a keyboard, a touch screen, a microphone and / or a remote controller. The output device 308 can be any type of device capable of presenting information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator and / or a printer.
[0048] The computing device 300 may also include or be connected to a non-transitory storage device 314, which may be any non-transitory storage device that can implement data storage, and may include, but is not limited to, a disk drive, an optical storage device, a solid-state memory, a floppy disk, a flexible disk, a hard disk, a tape, or any other magnetic medium, a compressed disk or any other optical medium, a cache memory, and / or any other storage chip or module, and / or any other medium from which a computer can read data, instructions, and / or code. The computing device 300 may also include a random access memory (RAM) 310 and a read-only memory (ROM) 312. The ROM 312 may store programs, utilities, or processes to be executed in a non-volatile manner. The RAM 310 may provide volatile data storage and store instructions related to the operation of the computing device 300. The computing device 300 may also include a network / bus interface 316 coupled to a data link 318. The network / bus interface 316 can be any type of device or system capable of enabling communication with external devices and / or networks, and can include but is not limited to modems, network cards, infrared communication devices, wireless communication devices and / or chipsets (such as Bluetooth™ devices, 802.11 devices, WiFi devices, WiMax devices, cellular communication facilities, etc.).
[0049] The present disclosure may be implemented as any combination of an apparatus, a system, an integrated circuit, and a computer program on a non-transitory computer-readable medium. One or more processors may be implemented as an integrated circuit (IC), an application specific integrated circuit (ASIC), or a large scale integrated circuit (LSI), a system LSI, a super LSI, or a super LSI component that performs some or all of the functions described in the present disclosure.
[0050] The present disclosure includes the use of software, applications, computer programs, or algorithms. The software, applications, computer programs, or algorithms may be stored on a non-transitory computer-readable medium to enable a computer such as one or more processors to perform the above steps and the steps described in the accompanying drawings. For example, one or more memories store the software or algorithm in executable instructions, and one or more processors may associate a set of instructions to execute the software or algorithm to provide various functions according to the embodiments described in the present disclosure.
[0051] Software and computer programs (which may also be referred to as programs, software applications, applications, components or code) include machine instructions for a programmable processor and may be implemented in a high-level procedural language, an object-oriented programming language, a functional programming language, a logic programming language, or an assembly language or a machine language. The term "computer-readable medium" refers to any computer program product, apparatus or device for providing machine instructions or data to a programmable data processor, such as magnetic disks, optical disks, solid-state storage devices, memories and programmable logic devices (PLDs), including computer-readable media that receive machine instructions as computer-readable signals.
[0052] For example, computer readable media may include dynamic random access memory (DRAM), random access memory (RAM), read-only memory (ROM), electrically erasable read-only memory (EEPROM), compact disk read-only memory (CD-ROM) or other optical disk storage devices, magnetic disk storage devices or other magnetic storage devices, or any other medium that can be used to carry or store the desired computer readable program code in the form of instructions or data structures and can be accessed by a general or special purpose computer or a general or special purpose processor. As used herein, disk or disc includes compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks usually reproduce data magnetically, while discs reproduce data optically by laser. Combinations of the above are also included in the scope of computer readable media.
[0053] The subject matter of the present disclosure is provided as an example of devices, systems, methods and programs for performing the features described in the present disclosure. However, in addition to the above-mentioned features, other features or variations may also be expected. It is expected that the implementation of the components and functions of the present disclosure may be completed with any emerging technology that may replace any of the above-mentioned implementation technologies.
[0054] In addition, the above description provides examples without limiting the scope, applicability or configuration set forth in the claims. Without departing from the spirit and scope of the present disclosure, the functions and arrangements of the elements discussed may be changed. Various embodiments may appropriately omit, replace or add various processes or components. For example, features described with respect to certain embodiments may be combined in other embodiments.
[0055] Similarly, while operations are depicted in a particular order in the drawings, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed to achieve desired results. In certain circumstances, multitasking and parallel processing can be advantageous.
Claims
1. An automated testing method for an Android application, comprising: Divide the display screen of the test device into N click blocks, where N is an integer greater than 1, and generate a click position matrix by elements including click position coordinate information corresponding to each click block; Get the initial startup activity Activity and start the application APP, and store the screenshot of the current page; Click N click blocks on the display screen in a predetermined order to trigger a click event, and store a screenshot of the page of the Activity that is jumped to after the click; Compare the screenshot of the page before the click with the screenshot of the page after the click to determine the similarity between the two; When it is determined that the similarity is less than a predetermined threshold, the current click event is determined to be a valid click event, and the position coordinate information of the element in the click position matrix corresponding to the valid click event is stored in the test case library; In the case where it is determined that the clicks on the N click blocks have been completed or a page screenshot that meets the conditions for terminating the clicks has been detected, the position coordinate information corresponding to the valid click events and stored in the test case library is collected to form a valid click chain, wherein each position coordinate information in the valid click chain corresponds to an Activity of the tested application, and the page screenshot that meets the conditions for terminating the clicks includes a keyword associated with the conditions for terminating the clicks; as well as By automatically clicking the corresponding click blocks on the display screen according to the valid click chain, the Activities of the same or similar applications are automatically traversed.
2. The method according to claim 1, further comprising: The conditions for terminating the click are set. When it is detected that the screenshot of the page of the Activity jumped to by the click includes a keyword associated with the set conditions for terminating the click, the click is terminated and the test ends.
3. The method according to claim 1 or 2, wherein comparing the screenshot of the page before the click with the screenshot of the page after the click comprises: Image recognition technology is used to extract image features of the page screenshot before clicking and the page screenshot after clicking for comparison.
4. The method according to claim 1 or 2, wherein the display screen of the test device is divided into N click blocks, and generating a click position matrix from elements including click position coordinate information corresponding to each click block comprises the following steps: Initialize the real machine / simulator device used for automated testing and obtain the length and width of the display screen of the test device; Dividing the display screen equally according to the length and width of the display screen by a predetermined number of pixels or dividing the display screen in any appropriate manner; and A click position matrix is generated by elements including click position coordinate information corresponding to each click block.
5. The method according to claim 1 or 2, further comprising: According to the correspondence between the click block on the display screen and the corresponding Activity, the click coordinate position is located on the display screen for the specified Activity, and the specified Activity is tested by clicking the located click coordinate position.
6. The method according to claim 1 or 2, further comprising: Traverse the Android application package APK directory name and file name, and determine whether the APK is a native Android application package by querying the unity, cocos, and ue4 keywords.
7. An automated testing system (100) for Android applications, comprising: A click position matrix generating unit (101) is used to divide the display screen of the test device into N click blocks, where N is an integer greater than 1, and to generate a click position matrix based on elements including click position coordinate information corresponding to each click block; A click event triggering unit (102), configured to trigger a jump to an activity corresponding to click position coordinate information of the click block by clicking the click blocks divided on the display screen in a predetermined order; A storage unit (103), used to store click position coordinate information of each click block on the display screen and a screenshot of the page of the Activity to which the click jumps; A comparison unit (104), used to compare the page screenshot before the click and the page screenshot obtained after the click to determine the similarity between the two, and compare the similarity with a predetermined threshold, and when the similarity is lower than the predetermined threshold, determine that the current click event is a valid click event; as well as The test case library (105) is used to store the position coordinate information of the elements in the click position matrix corresponding to each valid click event, and to form a valid click chain when the clicks on N click blocks are completed or a page screenshot that meets the conditions for terminating the click is detected, wherein each position coordinate information of the valid click chain corresponds to an Activity of the tested application, and the page screenshot that meets the conditions for terminating the click includes a keyword associated with the conditions for terminating the click, The automated testing system is configured to automatically traverse the Activities of the same or similar applications by automatically clicking corresponding click blocks on the display screen according to a valid click chain. 8 . A computer-readable storage medium having instructions stored thereon, wherein when the instructions are executed by a processor, the processor executes the method for automated testing of Android applications according to any one of claims 1 to 6.
Citation Information
Patent Citations
A test script generation method and device based on reinforcement learning
CN109901994A