Packaging method, testing method, electronic device and storage medium for application program

CN116048963BActive Publication Date: 2026-08-07TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
Filing Date
2022-12-21
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

然而,对于人工测试而言,一方面受限于终端机型、网络环境等外界因素,另一方面需要投入大量的测试人员成本并花费大量的测试时间,而无法稳定地、可追溯地触发这些异常问题,降低了开发人员在发布应用程序之前将其修复的可能性

Benefits of technology

[0055]在本申请实施例的用于应用程序的封装方案中,通过获取所述应用程序的原始的第一应用程序代码;通过AOP技术在所述原始的第一程序代码的多个切面插入异常激发代码以得到第二应用程序代码;编译已插入所述异常激发代码的第二应用程序代码以得到用于测试的应用程序安装包。由此获得的应用程序封装及相应的测试解决方案能够以对应用程序原始代码干扰最小化的方式注入异常激发代码,增大了测试过程中异常问题出现的概率,从而促成异常问题更早暴露,以免影响用户的使用体验。该解决方案的可配置性强、可迁移性高,显著降低配置、迁移难度并节省配置、迁移成本,而且还避免因注入异常激发代码而引起其他的潜在问题。由此,本申请实施例的方案显著提高了应用程序的可维护性和安全性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116048963B_ABST
    Figure CN116048963B_ABST
Patent Text Reader

Abstract

The application discloses an encapsulation method, a test method, an electronic device and a storage medium for an application. The encapsulation method for the application comprises the following steps: obtaining original first application code of the application; inserting exception triggering code into multiple aspects of the original first application code through AOP to obtain second application code; and compiling the second application code in which the exception triggering code has been inserted to obtain an application installation package for testing. The application encapsulation and the test solution thereof can inject the exception triggering code in a manner that minimizes interference with the original application code, increase the probability of occurrence of exception problems, and thus facilitate earlier exposure of the exception problems, so as to avoid affecting the user experience. The solution has strong configurability and high migratability, significantly reduces the configuration and migration difficulty and saves the configuration and migration cost, and further avoids other potential problems caused by the injection of the exception triggering code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method for packaging applications, a testing method, an electronic device, and a storage medium. Background Technology

[0002] With the development of computer technology, especially mobile terminal technology, a large number of applications have emerged. These applications may encounter various problems after delivery. Therefore, application providers conduct extensive testing before releasing an application for official use to minimize the possibility of anomalies or errors when the application is used by users.

[0003] Currently, the approach involves both manual and automated testing of installed applications. However, manual testing is limited by external factors such as terminal model and network environment, and requires significant investment of testers and testing time. It also struggles to reliably and traceably trigger these anomalies, reducing the likelihood of developers fixing them before application release. Automated testing typically requires the deployment of targeted test cases, which is highly effective for relatively fixed user interface layouts. However, it struggles to accurately identify and capture anomalies in non-standard user interface designs and layouts, such as the insertion of specific views. Especially for anomalies occurring in edge computing scenarios, neither manual nor automated testing can accurately identify, capture, or reliably reproduce them.

[0004] Therefore, we hope to provide a solution for application testing that can effectively increase the likelihood of identifying application anomalies during testing, thereby exposing anomalies before they occur during the testing phase and reducing the probability of users encountering anomalies during normal use.

[0005] The background description is provided for the purpose of understanding the relevant technologies in this field and is not intended as an admission of prior art. Summary of the Invention

[0006] Therefore, it is necessary to provide a method for encapsulating applications, a testing method, an electronic device, and a storage medium for addressing the aforementioned technical problems. This method can inject exception triggering code in a way that minimizes interference with the original application code, thereby increasing the probability of exceptions occurring during testing and facilitating earlier exposure of exceptions to avoid affecting the user experience.

[0007] In a first aspect, a method for encapsulating an application is provided, comprising:

[0008] Obtain the original first application code of the application;

[0009] Aspect-oriented programming (AOP) is used to insert exception-triggering code into multiple aspects of the original first program code to obtain the second application code;

[0010] Compile the second application code, into which the exception triggering code has been inserted, to obtain the application installer for testing.

[0011] In some embodiments, the insertion of exception-triggered code into multiple aspects of the original first program code via aspect-oriented programming (AOP) to obtain second application code includes:

[0012] The exception triggering code is inserted into the multiple aspects using the ASM framework.

[0013] In some embodiments, the exception triggering code is used to increase the probability that a given visual control will malfunction.

[0014] In some embodiments, the insertion of exception-triggered code into multiple aspects of the original first program code via aspect-oriented programming to obtain second application code includes:

[0015] Identify the visual controls to be used for anomaly testing;

[0016] Based on the identified visual control, determine the target class associated with the exception test of the visual control;

[0017] Based on the identified visual control, determine the target function of the target class associated with the anomaly test of the visual control;

[0018] Based on the anomaly, the relative insertion position of the anomaly triggering code relative to the objective function is determined.

[0019] In some embodiments, the relative insertion position includes the exception triggering code before the target function, after the target function, and before and after the target function, respectively.

[0020] In some embodiments, determining the relative insertion position of the exception triggering code relative to the target function based on the exception includes:

[0021] An exception trigger code for randomly generating delays is inserted before the target function, which is a function associated with the visual control passing size information to the parent control.

[0022] In some embodiments, the target class is the parent control class of the visual control, and the target function of the target class is the creation function of the parent control class.

[0023] In some embodiments, the exception triggering code is used to generate a random delay based on a random seed when executed.

[0024] In a second aspect, a testing method for an application is provided, comprising:

[0025] The application installation package for testing is obtained by packaging the application using the packaging method for the application according to any embodiment of this application;

[0026] Install the application installation package in the terminal to obtain the installed application;

[0027] The installed application is tested to obtain the test results.

[0028] In some embodiments, testing the installed application includes:

[0029] Perform one or more given manual test actions on the terminal where the application is installed.

[0030] In some embodiments, testing the installed application includes:

[0031] An automated test script is loaded and executed by a terminal that has the application installed to automatically perform one or more automated test actions, wherein the automated test script records the one or more automated execution actions, execution time, and execution order.

[0032] In some embodiments, testing the installed application includes:

[0033] The testing of the installed application includes:

[0034] Trigger the creation of the visual control;

[0035] In response to the triggering of the creation of the visual control, the target class is filtered out from all classes in the application by querying the class name;

[0036] In response to the triggering of the creation of the visual control, the target function is filtered out in the target class by querying the function name;

[0037] Based on the relative insertion position, the exception triggering code and the target function of the target class are executed accordingly.

[0038] In a further embodiment, testing the installed application includes:

[0039] The creation of the visual control is triggered multiple times;

[0040] In response to each triggering of the creation of the visual control, the visual control passes its size information to its parent control;

[0041] The delay is randomly generated by the exception triggering code, thereby randomly delaying or not delaying the transmission of the size information;

[0042] The parent control allocates drawing space for the visual control;

[0043] The visualization control is drawn based on the drawing space;

[0044] In at least one of the triggers that create the visualization control, the delay in the random generation of the exception trigger code ensures that the transmission of the size information is completed after the allocation of the drawing space or the drawing of the visualization control.

[0045] In a third aspect, a packaging device for an application is provided, comprising:

[0046] The acquisition unit is configured to acquire the original first application code of the application.

[0047] An insertion unit is configured to insert exception-triggered code into multiple aspects of the original first program code via aspect-oriented programming to obtain second application code.

[0048] The compilation unit is configured to compile second application code into which the exception triggering code has been inserted to obtain an application installer for testing.

[0049] In a fourth aspect, a testing apparatus for an application is provided, comprising:

[0050] The packaging unit is configured to package the application installation package for testing using the packaging method for applications according to any embodiment of this application.

[0051] The installation unit is configured to install the application installation package in the terminal to obtain the installed application;

[0052] The testing unit is configured to test the installed application and obtain the test results of the application.

[0053] In a fifth aspect, an electronic device is provided, comprising: a processor and a memory storing a computer program, the processor being configured to implement the method described in any embodiment of the present application when running the calculator program.

[0054] In a sixth aspect, a storage medium is provided, characterized in that the storage medium stores a computer program configured to be executed to implement the methods described in any embodiment of the present application.

[0055] In the application packaging scheme of this application embodiment, the original first application code of the application is obtained; exception triggering code is inserted into multiple aspects of the original first application code using AOP technology to obtain second application code; the second application code with the inserted exception triggering code is compiled to obtain an application installation package for testing. The resulting application packaging and corresponding testing solution can inject exception triggering code in a way that minimizes interference with the original application code, increasing the probability of exceptions occurring during testing and thus facilitating earlier exposure of exceptions to avoid affecting the user experience. This solution is highly configurable and portable, significantly reducing configuration and migration difficulty and saving configuration and migration costs, and also avoiding other potential problems caused by injecting exception triggering code. Therefore, the solution of this application embodiment significantly improves the maintainability and security of the application.

[0056] This invention is presented in a simplified form to introduce some concepts, which will be further described in the following description. This invention does not intend to identify the essential features of the claimed technical solutions. Furthermore, the claimed technical solutions are not limited to embodiments that address all the disadvantages pointed out in any part of this document.

[0057] Other optional features and technical effects of the embodiments of the present invention are partly described below and partly apparent from reading this document. Attached Figure Description

[0058] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings. The elements shown are not limited to the scale shown in the drawings, and the same or similar reference numerals in the drawings denote the same or similar elements, wherein:

[0059] Figure 1A An exemplary flowchart of an application encapsulation method according to an embodiment of the present invention is shown;

[0060] Figure 1B An exemplary flowchart of an application encapsulation method according to an embodiment of the present invention is shown;

[0061] Figure 2 An exemplary process diagram for implementing embodiments of the present invention is shown.

[0062] Figure 3A An exemplary architecture diagram of aspect-oriented programming (AOP) technology applicable to the methods of embodiments of the present invention is shown;

[0063] Figure 3B An exemplary architecture diagram of aspect-oriented programming (AOP) technology applicable to the methods of embodiments of the present invention is shown;

[0064] Figure 3C An exemplary architecture diagram of aspect-oriented programming (AOP) technology applicable to the methods of embodiments of the present invention is shown;

[0065] Figure 4 An exemplary process diagram of view rendering is shown when implementing the method of an embodiment of the present invention;

[0066] Figure 5A An exemplary flowchart of a testing method for an application according to an embodiment of the present invention is shown;

[0067] Figure 5B An exemplary flowchart of a testing method for an application according to an embodiment of the present invention is shown;

[0068] Figure 5C An exemplary flowchart of a testing method for an application according to an embodiment of the present invention is shown;

[0069] Figure 6 A schematic diagram of the structure of a packaging device for an application according to an embodiment of the present invention is shown;

[0070] Figure 7 A schematic diagram of the structure of a testing apparatus for an application according to an embodiment of the present invention is shown;

[0071] Figure 8 A schematic diagram of an exemplary hardware structure of a mobile terminal capable of implementing a testing method for an application according to an embodiment of the present invention is shown.

[0072] Figure 9 A schematic diagram of an exemplary operating system architecture for a mobile terminal capable of implementing a testing method for an application according to embodiments of the present invention is shown; and

[0073] Figure 10 A schematic diagram of an electronic device capable of implementing the methods of embodiments of the present invention is shown. Detailed Implementation

[0074] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.

[0075] The term "comprising" and its variations as used herein signify open inclusion, i.e., "including but not limited to". Unless otherwise stated, the term "or" means "and / or". The term "based on" means "at least partially based on". The terms "one example embodiment" and "one embodiment" mean "at least one example embodiment". The term "another embodiment" means "at least one additional embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.

[0076] The applications described in this application embodiment can have the normal meaning understood by those skilled in the art, and are sometimes referred to as software. The applications described in this application embodiment can be of various types, including but not limited to social applications, music applications, video / short video applications, file management applications, email applications, shopping applications, or game applications, or composite applications combining multiple functions. Social applications include instant messaging applications, SNS (Social Network Service) applications, or live streaming applications, etc.

[0077] The applications described in this application can be installed on a terminal or client, while the solutions described in this application can be implemented, partially or wholly, on one or more devices remote from the terminal or client, such as a server or a test device independent of the server. For example, the application packaging method and apparatus according to the embodiments of this application can be implemented in a test device.

[0078] The applications described in this application can be applied to the Android operating system or Android-based operating systems, but are not limited to this. The applications described in this application can be written in various languages, specifically Java, Kotlin, etc., but are not limited to these. In this document, Java will be used as an example to present some exemplary examples, but those skilled in the art will be able to implement the embodiments of this invention in other languages ​​under the teachings of this invention, which falls within the scope of this invention.

[0079] Currently, before an application is officially released for use, application providers conduct extensive testing to minimize the possibility of exceptions or errors when the application is used by users.

[0080] For manual or automated tests used in application testing, in certain situations, such as the insertion of specific views, it is difficult to reliably and traceably trigger these abnormal issues or accurately identify and capture them, especially in edge scenarios.

[0081] Therefore, the inventors have unexpectedly injected exception-triggering code in a manner that minimizes intervention in the application's original code (source code) to increase the probability of exceptions occurring during testing, thereby facilitating earlier exposure of exceptions. Furthermore, the inventors have intentionally made the injected exception-triggering code highly configurable and portable, thereby improving its removability to avoid other potential problems caused by the injected exception-triggering code, while also reducing the ease of testing the same or similar types of exceptions in other applications.

[0082] To address this, embodiments of this application provide a method and apparatus for encapsulating applications, a corresponding testing method and apparatus, an electronic device, and a computer-readable medium. By using aspect-oriented programming (AOP) technology to inject exception-triggering code, the method minimizes interference with the original application code, increasing the probability of exceptions occurring and facilitating earlier detection to avoid impacting the user experience. Furthermore, the solution of this application is highly configurable and portable, significantly reducing configuration and migration difficulty and costs, and also avoiding other potential problems caused by injecting exception-triggering code.

[0083] The specific embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0084] For example Figure 1A The diagram illustrates a method for packaging an application according to an embodiment of the present invention. This method may include steps S110 to S130:

[0085] S110: Obtain the original first application code of the application.

[0086] In this article, the original application code is referred to as the project source code, or simply source code.

[0087] Combination Figure 1A and Figure 2 As shown, in this embodiment of the application, step S110 or a separate step may include configuring a test pipeline. Combined with... Figure 1A and Figure 2 As shown, in some embodiments, the application's project source code can be pulled after configuring the test pipeline.

[0088] In some embodiments, configuring a test pipeline may include configuring a CI (Continuous Integration) test pipeline or a CD (Continuous Computing) test pipeline. Through CI / CD pipelines, software development can proceed in a pipeline from code check-in, testing, building, and deployment all the way to the production stage, which will not be elaborated upon here.

[0089] In some embodiments, step S110 or a separate step may include configuring environment parameters, frameworks, plugins, etc., for testing the encapsulation. In one specific embodiment, for example, framework and / or environment configuration parameters based on AOP may be configured, as described below. In a specific example, the ASM framework may be introduced and its environment parameters configured to make it pluggable, as described below, which can be achieved when configuring the test pipeline.

[0090] S120: By inserting exception-triggered code into multiple aspects of the original first program code through aspect-oriented programming (AOP) to obtain the second application code.

[0091] The exceptions described in this application have the normal meaning in the art. In some places in this document, the exceptions may include errors or be used interchangeably, covering various defects and faults of the application, including functional abnormalities or abnormal interruptions, data loss, crashes, lag, frame drops, etc. that occur during the operation of the application.

[0092] In this embodiment, the exception triggering code is used to trigger or facilitate the occurrence of an exception, that is, to increase the probability of an exception occurring, but not to directly (100%) cause an exception or error. In this embodiment, the exception triggering code can be code that increases the probability of a given exception or error occurring, or it can be code that increases the probability of multiple unspecified exceptions or errors occurring.

[0093] In some embodiments, the exception triggering code is used to increase the probability of a given visual control exhibiting an anomaly. This will be further described below with specific examples.

[0094] Reference Figure 1A and Figure 2 This illustration depicts an example architecture of Aspect-Oriented Programming (AOP) technology and its application in the methods of embodiments of the present invention.

[0095] AOP stands for Aspect-Oriented Programming. More specifically, AOP uses pre-compilation and dynamic proxies to dynamically and uniformly add specific functionalities to a program in multiple independent locations, also known as aspects, without modifying the source code.

[0096] Currently, there are proposals to use AOP to insert non-core business functions into business models, such as injected logs and practical applications, which may span multiple business models, thereby saving the need to repeatedly write code in each business model. However, the inventors here do not use AOP to implement general functions that are not business functions. Instead, in this embodiment, AOP is used to insert exception triggering code into multiple aspects, thereby minimizing the interference of the inserted exception triggering code with the original code (source code). Specifically, this embodiment inserts exception triggering code into aspects in an instrumentation manner, without modifying the original code (source code), and therefore without worrying about other interference to the source code. Moreover, the exception triggering code inserted in this way also enjoys better configurability and portability.

[0097] In the embodiments of this application, there are various specific implementation methods for inserting (inserting) exception triggering code in multiple aspects based on aspect-oriented programming (AOP).

[0098] In one implementation, for example Figures 3A to 3C As shown, exception-triggered code can be inserted (instrumented) into the application's original code (source code) via a proxy in the form of an aspect. Thus, when, for example, the client executes the source code, and the method to be called (reaching the aspect) is about to execute the exception-triggered code, the calling method is intercepted, and the exception-triggered code is executed during the interception. This is similar to how the execution flow of the source code is truncated at the point of attack using an "aspect," as... Figures 3A to 3C As shown. By setting a pointcut (entry point), an intercepting aspect (aspect 1) can be created accordingly. Here, the aspect can be understood as an interceptor. When the program runs to the pointcut, it is intercepted and optionally initialized. The interception can be ended by the relevant method of the exception triggering code that has been destroyed. This will be further described below in conjunction with specific embodiments of this application.

[0099] In these embodiments, there are various specific implementation methods for inserting exception-triggering code into aspects. In one specific example, when the programming language is Java, it can be dynamically inserted at runtime through a third-party framework or the JVM's dynamic proxy functionality. In other examples, it is conceivable that the compiler compiles the aspect calls into the bytecode at compile time, defining new keywords and extending the compiler to implement instrumentation. In other examples, it is conceivable to re-enhance the bytecode of the aspect target class through a specific class loader.

[0100] In some embodiments, the ASM underlying framework technology is used to implement the Aspect-Oriented Programming (AOP). For example, the ASM framework can be used to insert the exception triggering code into multiple aspects.

[0101] In an interpretive and not restrictive sense, ASM is a framework for implementing AOP (Aspect-Oriented Programming). It performs instrumentation at the Java bytecode level, dynamically generating classes or enhancing the functionality of existing classes. Specifically, ASM can directly generate binary class files or dynamically modify class behavior before the class is loaded into the Java Virtual Machine. Furthermore, the ASM framework provides common bytecode analysis and generation tools for quickly generating, querying, or analyzing and transforming classes.

[0102] In some embodiments, the exception triggering code is used to increase the probability of an exception occurring in a given visual control. As mentioned earlier, current testing methods struggle to accurately identify and capture exceptions in non-standard user interface designs and layouts, such as the insertion of specific views. Therefore, the exception triggering code in this application embodiment is used to increase the probability of exceptions occurring in these scenarios.

[0103] In such Figure 1B In the specific embodiment shown, step S120 may include:

[0104] S121: Determine the visual controls to be used for anomaly testing;

[0105] S122: Based on the determined visual control, determine the target class associated with the exception test of the visual control;

[0106] S123: Based on the determined visual control, determine the target function of the target class associated with the anomaly test of the visual control;

[0107] S124: Based on the anomaly, determine the relative insertion position of the anomaly triggering code relative to the target function.

[0108] The following will combine Figure 1B and Figure 2 , Figures 3A to 3C as well as Figure 4 Several specific embodiments according to this application are described.

[0109] In the embodiments of this application, the visual control has the normal meaning in the art, such as the visual representation of a view.

[0110] As an explanation, particularly when applied to Android or Android-based operating systems or similar operating systems according to embodiments of this application, an activity is one of the four major components of Android, used to represent a visual interface for user operations, providing the user with an interface to complete operation commands. An activity has its own lifecycle and accordingly executes methods such as onCreate, onStart, and onResume.

[0111] In the tree structure, under an activity, there are windows or phone windows that are inherited from each other. Under a window, there are views or view groups that are inherited from each other.

[0112] Furthermore, in this embodiment, View (view class) is an abstraction of visual controls in the user interface layer, representing the corresponding controls. In some embodiments, controls can also be called containers; for example, a parent control can be a container that holds child controls.

[0113] Furthermore, for a View, it can form a hierarchical structure of related inheritance and containing parent and child views. In some parts of this text, View may also be referred to as a layout. It will become clear that within the View's tree structure, the measurement, drawing, and event dispatching of Activities, Windows, and Views are passed hierarchically through the tree structure.

[0114] Accordingly, child view classes of a parent view class (such as a root view) can be defined in the code. Similarly, by placing a first control (container) inside a second control (container), the second control (container) can become the parent control (container) of the first control, or the first control can become a child control (container) of the second control (container). Correspondingly, parent / child view classes and parent / child controls (containers) can be incorporated into the tree structure of the View as described above to pass parameters. This is known in the art and will not be elaborated further here. Furthermore, the embodiments of this application explicitly cover technical solutions that have the features of this invention but are expressed in different forms (such as views, controls, and containers), and all such technical solutions fall within the scope of this invention.

[0115] In some embodiments, the visual controls described in this application may include any feasible visual controls, including but not limited to text, text editing boxes, buttons, links, images, etc.

[0116] Continue to combine with references Figure 1B and Figure 2 , Figures 3A to 3C In step S121, specific controls / containers / Views of the application to be used for exception testing can be determined. For example, requirements analysis can be performed on newly added controls / containers / Views in order to conduct exception testing.

[0117] In one example, the control / container / View used for exception testing might be the application's activity page. For instance, an application provider might want to add an activity navigation feature to the application's message page (a primary page), allowing users to jump to an activity link by pulling down the message page. This requirement necessitates dynamically creating an activity page control (View) to display the activity cover.

[0118] In a further embodiment, the cause of the abnormal problem of the control / container / View is further analyzed and determined in step S121 or as a separate step. Furthermore, this allows for the determination of an instrumentation scheme for the exception-triggered code.

[0119] For example, in a specific instance, when dynamically creating a visual control (View), it is necessary to adapt the size (such as width and height) of the visual control (View) to fit different screen sizes. To address this need, we can identify and analyze the exception caused by dynamically obtaining the View's width and height as 0, so as to determine the instrumentation scheme for the exception-triggered code by analyzing the business source code.

[0120] Reference Figure 4 This explains why it's not necessary to measure the size of the visual control (View) when it's created. However, to draw the visual control (View), for example, to accommodate different screen sizes, the dimensions (such as width and height) of the visual control (View) need to be adapted when drawing a new one. Accordingly, normally, the parent control might call the child control's `onMeasure()` method to measure the child control's dimensions (such as width and height); then, it might allocate a drawing control for the child control to use for drawing / rendering. Specifically, this involves passing in parameters `widthMeasureSpec` and `heightMeasureSpec`, which inform the child control of the available space and constraints related to that space. The parent control can then dynamically draw the visual control (or its corresponding View) based on that space and constraints, for example, using the `addView` method.

[0121] However, the inventors discovered that the lifecycle of the parent control (or a higher-level node) and the drawing of the newly added child control (View) may not be synchronized. For example, the Activity may fail to measure the size of the newly added child control (View) after executing onCreate, onStart, and onResume, causing the child control to be unable to pass valid size information to the parent control. In other words, the parent control obtains a child control size (width and height) of 0. Therefore, an abnormal problem may occur when drawing the child control (View) because the parent control obtains a child control size (width and height) of 0.

[0122] Furthermore, in step S122, the target class file associated with the anomaly test of the determined visual control can be determined based on the determined visual control. More specifically, the target class file can be determined based on the newly added visual control and the cause of the anomaly.

[0123] Similarly, in step S123, the target function of the target class associated with the exception test of the determined visual control can be determined based on the determined visual control. More specifically, the target function can be determined based on the newly added visual control and the cause of the exception.

[0124] Further, in step S124, the relative insertion position of the exception triggering code relative to the target function can be determined based on the exception. More specifically, the relative insertion position can be determined based on the newly added visual control and the cause of the exception. In this embodiment of the application, in step S124 or in a separate step, the function and role of the exception triggering code can also be determined based on the newly added visual control and the cause of the exception.

[0125] In a further embodiment, the relative insertion position includes the exception triggering code before the target function, after the target function, and both before and after the target function. Figure 3A A schematic example is shown where the exception triggering code is truncated (preceded) before the target function; Figure 3B A schematic example is shown where the exception triggering code is truncated (postponed) after the objective function; Figure 3C The diagram illustrates a schematic example of how the aspect (insertion position) of the exception triggering code is placed before and after (around) the objective function.

[0126] In the exemplary example of this application, steps S122 to S124 can be implemented based on the ASM framework. In this specific example, the ASM framework can be plugged in and introduced into the project to quickly and accurately obtain functions (methods) and the calling relationships between functions, as well as class information.

[0127] More specifically, target class (file) queries and target function queries can be implemented using the ASM framework. For example, in this specific example, this can be achieved through ASM framework configuration and code rewriting:

[0128] Class Name Lookup: The inventors realized that the Android compilation process compiles Java files into class files, and the ASM plugin can directly read the class files and obtain all class names. Class names can help filter target classes, facilitating instrumentation within the target class (file) and injecting exception-triggering code. In this specific example, for instance, addressing an exception caused by the parent control obtaining child control dimensions (width and height) of 0, the target class would be, for example, the class corresponding to the parent control.

[0129] Function name (methodName) lookup: Class files contain the names of all functions. The class file is the parent file of each function. The ASM framework can directly read the function names from each class file. Function names help filter target functions, facilitating the injection of exception-triggered code at a relative position within the target function. In this specific example, for instance, addressing the exception caused by the parent control obtaining child control dimensions (width and height) of 0, the target function could be, for example, the creation function of the parent control class, more specifically, the `onCreateRootView` function of the root view.

[0130] As mentioned earlier, different forms of exception-triggered code insertion, such as pre-position, post-position, and around-position, can be achieved through ASM framework configuration and code rewriting. As an example, pre-position or post-position insertion of exception-triggered code can be achieved by rewriting the following functions in the ASM framework:

[0131] org.objectweb.asm.MethodVisitor#visitCode (Pre-Injection): This function overrides the visitCode function to insert exception-triggered code at the bytecode level. Its purpose is to ensure that the injected code is executed before the target function, thus performing exception testing.

[0132] org.objectweb.asm.MethodVisitor#visitEnd (Post-Injection): This function overrides the visitEnd function. The method of inserting exception-triggered code is similar to overriding the visitCode function. The difference is that its function is to execute the injected code after the target function itself has been executed, thus serving as an exception test.

[0133] You can also bypass certain target functions by rewriting functions or creating new functions, such as bypassing the onMeasure function.

[0134] In such Figure 4In the illustrated embodiment, the relative insertion position of the exception triggering code with respect to the target function is determined to be before, more specifically, before the creation function onCreateRootView of the parent control class, such as the root view.

[0135] In a further embodiment, the exception triggering code is used to generate a random delay based on a random seed when executed.

[0136] For example, to ensure the robustness of the solution, an exception triggering code can be written to introduce the concept of a random seed. The layout rendering delay time is between [0, 3000ms). Each time the exception triggering code is executed, the random seed will throw a different delay time.

[0137] Those skilled in the art will understand that the above step S120 of inserting exception triggering code from the aspect can be implemented based on other frameworks or methods of AOP technology, which falls within the embodiments of this application.

[0138] S130: Compile the second application code with the exception triggering code inserted to obtain the application installer for testing.

[0139] Based on this, a favorable encapsulation scheme can be obtained for testing exceptions where the width and height of a View may be 0 when dynamically obtained.

[0140] Furthermore, a highly configurable and portable testing scheme can be designed based on the principles of AOP.

[0141] For example Figure 5A The diagram illustrates a testing method for an application according to an embodiment of the present invention. This testing method for an application may include steps S510 to S530:

[0142] S510: The application installation package for testing is obtained by using the packaging method for the application.

[0143] S520: Install the application installation package in the terminal to obtain the installed application;

[0144] S530: Test the installed application and obtain the test results of the application.

[0145] In some embodiments, the encapsulation method is the encapsulation method described in other embodiments of the present invention.

[0146] In some embodiments, exception triggering code is inserted into the application code used to generate the application installation package. The application code with the exception triggering code inserted is, for example, the second application code described in other embodiments.

[0147] In some embodiments, the terminal is an Android-based terminal, such as a mobile terminal. In some embodiments, the terminal based on an installed operating system, such as a mobile terminal, can be a terminal based on native Android or a terminal based on a modified Android operating system. It is also conceivable that the terminal is based on other operating systems. The following will combine... Figure 6 and Figure 7 The description provides specific examples of terminals that can be used in embodiments of this application.

[0148] In a preferred embodiment of the present invention, the mobile terminal may be a smartphone. This is merely an exemplary implementation. Figure 6 A schematic diagram of the hardware structure of a specific embodiment of a terminal, such as a mobile terminal 600, or a smartphone, is shown; while Figure 7 This diagram illustrates a system architecture of a specific embodiment of a terminal, such as a mobile terminal 600 or a smartphone, and more specifically, a layered architecture diagram of the Android operating system. Figure 6 and Figure 7 The terminal example shown can also be used to implement the testing method described in the embodiments of the present invention.

[0149] In the illustrated embodiments, the terminal, such as mobile terminal 600, may include a processor 601, an external memory interface 612, an internal memory 610, a universal serial bus (USB) interface 613, a charging management module 614, a power management module 615, a battery 616, a mobile communication module 640, a wireless communication module 642, antennas 639 and 641, an audio module 634, a speaker 635, a receiver 636, a microphone 637, a headphone jack 638, buttons 609, a motor 608, an indicator 607, a Subscriber Identity Module (SIM) card interface 611, a display screen 605, a camera device 606, and a sensor module 620, etc.

[0150] It is understood that the structure illustrated in the embodiments of this application does not constitute a specific limitation on the mobile terminal 600. In other embodiments of this application, the mobile terminal 600 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0151] In some embodiments, processor 601 may include one or more processing units. In some embodiments, processor 601 may include one or a combination of at least two of the following: application processor (AP), modem processor, baseband processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, neural network processor (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0152] The controller can serve as the nerve center and command center of the mobile terminal 600. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.

[0153] The processor may also include memory for storing instructions and data. In some embodiments, the memory in the processor is a cache memory. This memory can store instructions or data that the processor has just used or that are used repeatedly. If the processor needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 601, and thus improves the efficiency of the system.

[0154] NPU stands for Neural Network (NN) Computing Processor. By drawing inspiration from the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can quickly process input information and continuously learn on its own.

[0155] A GPU is a microprocessor for image processing, connected to a display screen and an application processor. GPUs perform mathematical and geometric calculations for graphics rendering. A processor may include one or more GPUs, which execute program instructions to generate or modify display information.

[0156] A digital signal processor (ISP) is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals.

[0157] In some embodiments, the processor 601 may include one or more interfaces. The interface may include an integrated circuit (I2C) interface, an integrated circuit built-in audio (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous transceiver (UART) interface, a mobile industry processor interface (MIPI), a general purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, a universal serial bus (USB) interface, etc.

[0158] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a limitation on the structure of the mobile terminal. In other embodiments of this application, the mobile terminal may also adopt different interface connection methods or a combination of multiple interface connection methods as described in the above embodiments.

[0159] The wireless communication function of the mobile terminal 600 can be implemented through antennas 639 and 641, mobile communication module 640, wireless communication module 642, modem processor or baseband processor, etc.

[0160] Video codecs are used to compress or decompress digital video.

[0161] The mobile terminal 600 can implement audio functions through an audio module, speaker, receiver, microphone, headphone jack, and application processor, such as music playback and recording.

[0162] The audio module is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals.

[0163] A microphone is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can put their mouth close to the microphone to speak, inputting the sound signal into the microphone.

[0164] Sensor module 620 may include one or more of the following sensors:

[0165] The pressure sensor 623 is configured to sense pressure signals and convert them into electrical signals.

[0166] The 624 bar pressure sensor is used to measure bar pressure.

[0167] The magnetic sensor 625 includes a Hall sensor.

[0168] The gyroscope sensor 627 can be used to determine the motion posture of the mobile terminal 600.

[0169] Accelerometer 626 can detect the magnitude of acceleration of mobile terminal 600 in various directions.

[0170] The distance sensor 629 can be configured to measure distance.

[0171] The proximity light sensor 621 may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode.

[0172] The ambient light sensor 622 is used to sense ambient light intensity.

[0173] The fingerprint sensor 631 can be configured to collect fingerprints.

[0174] The touch sensor 632 can be located on the display screen, and the touch sensor and the display screen together form a touch screen, also known as a "touchscreen". The touch sensor is used to detect touch operations applied to or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event, such as single click, double click, long press, tap, directional swipe, pinch, etc.

[0175] The bone conduction sensor 633 can acquire vibration signals.

[0176] The software operating system of electronic devices (computers), such as mobile terminals, can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture.

[0177] The embodiments shown herein illustrate the Android operating system platform in the form of a layered architecture, serving as an example to explain the software structure of a mobile terminal. However, it is conceivable that the embodiments described herein can be implemented in different software operating systems.

[0178] Figure 7 This is a schematic diagram of the Android operating system architecture. The solution of this embodiment of the invention can use the Android operating system. The layered architecture divides the software into several layers, which communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer 710, application framework layer 720, Android runtime and system library 730, and kernel layer 740.

[0179] Application layer 710 may include a series of application packages.

[0180] The Application Framework Layer 720 provides application programming interfaces (APIs) and a programming framework for applications within the application layer. The Application Framework Layer includes some predefined functions.

[0181] The window manager is used to manage window programs.

[0182] Content providers are used to store and retrieve data, and make that data accessible to applications.

[0183] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.

[0184] The phone manager is used to provide communication functions for mobile terminals.

[0185] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.

[0186] The notification manager allows applications to display notification information in the status bar. It can be used to convey informational messages and can disappear automatically after a short time without user interaction.

[0187] The Android Runtime comprises the core libraries and the virtual machine, and is responsible for the scheduling and management of the Android system. The core libraries consist of two parts: one part contains the functionalities that Java calls, and the other part contains the core Android libraries. The application layer and framework layer run within the virtual machine.

[0188] The system library can include multiple functional modules. The surface manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.

[0189] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

[0190] Kernel layer 740 is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, audio interfaces, sensor drivers, power management, and GPS interfaces. In some embodiments of the present invention, the display can invoke the display driver.

[0191] Furthermore, it is conceivable that the "terminal" is not a physical terminal, but rather other devices and / or software modules that simulate a terminal. For example, in another embodiment, the terminal is an emulator that simulates a terminal with an operating system installed, such as Android, which falls within the scope of the embodiments of this application.

[0192] In some embodiments, installing an application installation package on a terminal can be achieved by installing a local installation package file, such as an APK file on an Android-based terminal or its emulator.

[0193] In an alternative embodiment, installing the application installation package on the terminal can be achieved through an online store.

[0194] In some embodiments, testing the installed application includes performing one or more given manual test actions on the terminal where the application is installed.

[0195] As illustrated in Figure 3, after the project is compiled (packaged) and installed, the application, which has had exception-triggering code injected via AOP, can be tested manually. Such manual testing can include one or more independent human-computer interaction actions, multiple human-computer interaction actions in a given order, repeated human-computer interaction actions, using the application under different terminal / operating system configurations, or combinations thereof. Human-computer interaction actions include touch, text input, and / or voice input. Touch includes single-point touch, such as single click and double click, and multi-point touch, such as zoom, pan, and rotate.

[0196] In an alternative embodiment, testing the installed application includes: loading and executing an automated test script by the terminal where the application is installed to automatically perform one or more automated test actions, wherein the automated test script records the one or more automated execution actions, execution time, and execution order.

[0197] In this alternative embodiment, scripts for automated testing can be used to simulate the interactive actions and specific system configurations of manual testing. In automated testing, one or more test cases set in the automated test scripts can be used to test the application with a level of efficiency that manual testing cannot achieve due to time or effort, thereby identifying any potential anomalies.

[0198] Combination Figure 2 , Figures 3A to 3C and Figure 4 As shown, when the exception triggering code is used to increase the probability of an exception occurring in a given visual control, tests can be performed on the exceptions associated with that visual control.

[0199] In such Figure 5B In the specific embodiment shown, testing the installed application includes:

[0200] S521: Trigger the creation of the visual control;

[0201] S522: In response to the trigger of creating the visual control, the target class is filtered out from all classes in the application by querying the class name;

[0202] S523: In response to the trigger of creating the visual control, the target function is selected from the target class by querying the function name;

[0203] S524: Execute the exception triggering code and the target function of the target class accordingly, based on the relative insertion position.

[0204] In some embodiments, as previously described, the target class (file) selected is, for example, the parent control class.

[0205] In some embodiments, as previously described, the target function selected, for example, is the parent view creation function onCreateRootView.

[0206] In some embodiments, as previously described, for example, the relative insertion position (section) is the preceding insertion exception trigger code, such as... Figure 3A As shown.

[0207] In some embodiments, as previously described, the function of the exception triggering code is to introduce a random delay.

[0208] In some embodiments, testing can be performed for exceptions caused by a visual control (view) having a width and height of 0. As previously mentioned, these exceptions could be, for example, display errors in the visual control or application crashes.

[0209] In such Figure 5C In the specific example shown, testing the installed application may include:

[0210] S521': The creation of the visual control is triggered multiple times;

[0211] S522': In response to each trigger of the creation of the visual control, the visual control passes the size information of the visual control to its parent control;

[0212] S523': The delay is randomly generated by the exception triggering code, thereby randomly delaying or not delaying the transmission of the size information;

[0213] S524': The parent control allocates drawing space for the visual control;

[0214] S525': Draw the visualization control based on the drawing space.

[0215] In at least one of the triggers that create the visualization control, the delay in the random generation of the exception trigger code ensures that the transmission of the size information is completed after the allocation of the drawing space or the drawing of the visualization control.

[0216] In some embodiments, the aforementioned step S524 may include steps S522'-S525'.

[0217] In this embodiment, the creation of the visual control can be triggered multiple times through manual or automated testing. In a specific example, as mentioned earlier, the visual control is, for instance, an activity page displayed in the application, which can be accessed by clicking an activity link in a drop-down message page or pop-up window. Here, the creation of the visual control can be triggered by clicking the activity link through manual or automated testing.

[0218] In this embodiment, as previously described, the visual control, such as the activity page, needs to pass its size to the parent control when it is created, so that the parent control can allocate appropriate drawing space to complete the drawing (rendering) of the visual control (View). By way of explanation and not limitation, allocating appropriate drawing space by the parent control may be for example to adapt to different terminal screen sizes, but it could also be for other reasons. In this specific example, the parent control is, for example, the root view.

[0219] In this embodiment, by randomly delaying or not delaying the transmission of the visual control, such as the size information (width and height) of the activity page, the transmitted size information causes the parent control to obtain zero size information (width and height) of the visual control (View) in some tests (triggers). That is, the parent control only obtains the actual size information of the child control after the parent control allocates drawing space and even after the visual control draws (renders).

[0220] As described in the specific embodiments of this application, the delay in transmitting size information (such as width and height) can be achieved by delaying the size measurement of the visual control (View). That is, with an effective delay, the size measurement of the visual control (View) is not completed or even started before the parent control allocates drawing space for the visual control (View).

[0221] In a more specific embodiment, the delay in measuring the size of the visual control (View) is achieved by extending the rendering time of the parent control, such as the root view in the specific example. That is, with the effective delay, the parent control, such as the root view, is not drawn (rendered) before the parent control allocates drawing space for the visual control (View).

[0222] In this more specific embodiment, one particular implementation method is to override and call the code access (visitCode) function, so that the instrumented exception-prompting code is inserted as an aspect at the pointcut before the target function of the target class through AOP, such as through the ASM framework. This ensures that the exception-prompting code inserted in the form of an aspect is executed before the target function is executed. In a specific example, the target class is, for example, the class corresponding to the parent control (root view) of the visualization control (e.g., the class name is RootView), and the target function is, for example, the creation function of the parent control (e.g., the onCreateRootView function), as described above.

[0223] In a specific example, the exception triggering function may include code for generating random times. More specifically, the exception triggering function may introduce a random seed to randomly obtain an extension time that occurs within a given delay range, so that the rendering delay of the parent control is also within that given delay range, as described above.

[0224] In this embodiment, obtaining the test results of the application includes: identifying abnormal results and providing abnormal report data. In this document, abnormal report data may sometimes also be referred to as error report data. This report data may include abnormal or error location information. Additionally, the report data may optionally include log records and metadata.

[0225] In some embodiments, when manual testing is performed, the report data or at least a portion thereof, such as anomaly or error location, may be provided by the tester.

[0226] In other embodiments, during automated testing, a collection module for collecting exception reporting data can be installed on a terminal with the application installed, such as a mobile terminal. When an exception occurs during the application's automated testing, this collection module begins working to collect exception stack traces, log records, and metadata. In some embodiments, the collection module can be integrated into the original application or into an application injected with exception triggering code.

[0227] In these embodiments, the occurrence of application errors can also be monitored, for example, by monitoring through one or more monitoring units, modules and / or functions integrated into the application, so as to obtain or collect abnormality report data when an anomaly is detected, such as display anomaly, crash, freeze, frame drop, etc.

[0228] In some embodiments, the anomaly location information includes a stack trace to help locate the error location. In embodiments of this application, anomaly location information can be obtained through various means, particularly by integrating one or more units, modules, and / or functions that retrieve anomaly location information into an application.

[0229] In some embodiments, log records may also be referred to as operation logs, relating to operation records generated by the application during use. In embodiments of this application, log records can be obtained in various ways, such as through units, modules, and / or functions integrated into the application. In embodiments of this application, log records may include application log records. In other embodiments of this application, log records may further include system log records, which can be obtained, for example, through system-provided or modified logging tools, units, modules, and / or functions.

[0230] In some embodiments, meta information involves inherent information of the application and / or inherent information of the terminal running the application, such as a mobile terminal, including but not limited to device information, environmental information, and problem scenario marking information of the application and / or terminal, such as a mobile terminal, such as application version, language environment, language version, terminal brand, terminal model, terminal unique identifier, terminal system type, system version, etc.

[0231] In some embodiments, the method may further include: after identifying the abnormal result, submitting a bug fix request. Once an abnormality is identified, the bug fix request can be submitted automatically or by testers in the test pipeline to request developers to fix the problem; this will not be elaborated further here.

[0232] In the embodiments of this application, a packaging device and a testing device for the application are also provided accordingly.

[0233] like Figure 8 A packaging apparatus 800 for an application is illustrated according to an embodiment of the present invention. The packaging apparatus 800 may include an acquisition unit 810, an insertion unit 820, and a compilation unit 830. The acquisition unit 810 is configured to acquire the original first application code of the application. The insertion unit 820 is configured to insert exception-triggered code into multiple aspects of the original first application code via aspect-oriented programming to obtain second application code. The compilation unit 830 is configured to compile the second application code with the inserted exception-triggered code to obtain an application installation package for testing.

[0234] like Figure 9 A testing apparatus 900 for an application is shown according to an embodiment of the present invention. The testing apparatus 900 may include a packaging unit 910, an installation unit 920, and a testing unit 930. The packaging unit 910 is configured to package the application installation package for testing using a packaging method for applications according to any embodiment of the present application. The installation unit 920 is configured to install the application installation package on a terminal to obtain an installed application. The testing unit 930 is configured to test the installed application and obtain test results for the application.

[0235] The packaging and / or testing apparatus disclosed in the embodiments of this application can be implemented by software, hardware, firmware, or a combination thereof. The packaging and / or testing apparatus disclosed in the embodiments of this application can be implemented by one or more computer devices, such as a general-purpose computer or a special-purpose computer.

[0236] Under the teachings of this invention, features of method embodiments may be incorporated in a non-contradictory manner into apparatus, device, or storage medium embodiments or other method embodiments to obtain new embodiments, and features of apparatus embodiments may also be incorporated in a non-contradictory manner into method, device, or storage medium embodiments or other apparatus embodiments to obtain new embodiments, which falls within the scope of this invention.

[0237] In a further embodiment of this application, an electronic device is also provided, which may include a processor and a memory storing a computer program, the processor being configured to perform the method of any embodiment of this application when running the computer program.

[0238] Figure 10 A schematic diagram of an exemplary electronic device 1000 that can implement the methods of embodiments of this application is shown. In some embodiments, it may include more or fewer electronic devices than shown. In some embodiments, it may be implemented using a single or multiple electronic devices. In some embodiments, it may be implemented using cloud-based or distributed electronic devices.

[0239] like Figure 10 As shown, the electronic device 1000 includes a processor 1001, which can perform various appropriate operations and processes based on programs and / or data stored in read-only memory (ROM) 1002 or programs and / or data loaded from storage portion 1008 into random access memory (RAM) 1003. The processor 1001 can be a single-core or multi-core processor, or may include multiple processors. In some embodiments, the processor 1001 may include a general-purpose main processor (such as a CPU) and one or more special coprocessors, such as a graphics processing unit (GPU), a neural network processor (NPU), a digital signal processor (DSP), or other general-purpose or application-specific integrated circuits. Various programs and data required for the operation of the electronic device 1000 are also stored in RAM 1003. The processor 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0240] The processor and memory described above are used together to execute the program stored in the memory. When the program is executed by the computer, it can implement the steps or functions of the model generation method and recognition method described in the above embodiments.

[0241] The following components are connected to I / O interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a display and speakers, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card and a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. Drive 1010 is also connected to I / O interface 1005 as needed. Removable media 1011, such as a hard disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1010 as needed so that computer programs read from them can be installed into storage section 1008 as needed.

[0242] Figure 10 The electronic device shown is merely illustrative, but the electronic device according to embodiments of this application may include more than [other components]. Figure 10 The electronic device shown has more or fewer components or has more or fewer components than the one shown. Figure 10 The embodiments shown have the same, partially the same, or different architectures.

[0243] Although not shown, some embodiments also provide a computer-readable storage medium storing a computer program configured to be executed to perform the methods of any of the embodiments of this application. The computer program includes various program modules / units constituting the apparatus according to the embodiments of this application, and when executed, the computer program comprised of the various program modules / units can perform the functions corresponding to the various steps in the methods described in the above embodiments. The computer program can also run on electronic devices as described in the embodiments of this application.

[0244] The storage medium in embodiments of this application includes non-volatile and / or volatile articles that can store information by any method or technology. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0245] Those skilled in the art will understand that the embodiments of this specification can be implemented in various forms, such as methods, systems, or computer program products. Therefore, those skilled in the art will realize that the functional modules / units or controllers and related method steps described in the above embodiments can be implemented in software, hardware, or a combination of software and hardware.

[0246] Unless explicitly stated otherwise, the actions or steps of the methods and procedures described in the embodiments of this application do not necessarily have to be performed in a specific order and can still achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.

[0247] This document describes several embodiments, but for the sake of brevity, the descriptions of the embodiments are not exhaustive, and identical or similar features or parts between the embodiments may be omitted. In this document, "one embodiment," "some embodiments," "example," "specific example," or "some examples" refers to at least one embodiment or example applicable to this application, but not all embodiments. The above terms do not necessarily mean referring to the same embodiment or example. Without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of the different embodiments or examples.

[0248] The exemplary systems and methods of this application have been specifically shown and described with reference to the above embodiments, which are merely examples of the best mode for implementing the systems and methods. Those skilled in the art will understand that various changes can be made to the embodiments of the systems and methods described herein without departing from the spirit and scope of the invention as defined in the appended claims when implementing the systems and / or methods.

Claims

1. A method for encapsulating applications, characterized in that, include: Obtain the original first application code of the application; A second application code is obtained by inserting exception-triggered code into multiple aspects of the original first program code to increase the probability of exceptions occurring in the application. This includes: inserting exception-triggered code for randomly generating delays before the target function of a target class associated with an exception test of a given visual control, wherein the target class is the parent control class of the visual control, and the target function of the target class is the creation function of the parent control class, wherein the random delay generated by the exception-triggered code causes the parent control class to obtain the actual size information of the visual control only after allocating drawing space; Compile the second application code, into which the exception triggering code has been inserted, to obtain the application installer for testing.

2. The encapsulation method for applications according to claim 1, characterized in that, The step of inserting exception-triggered code into multiple aspects of the original first program code through aspect-oriented programming to increase the probability of exceptions occurring in the application, thereby obtaining the second application code, includes: The exception triggering code is inserted into the multiple aspects using the ASM framework.

3. The encapsulation method for applications according to claim 1 or 2, characterized in that, The exception triggering code is used to increase the probability that a given visual control will malfunction.

4. The method for encapsulating applications according to claim 3, characterized in that, The step of inserting exception-triggered code into multiple aspects of the original first program code through aspect-oriented programming to increase the probability of exceptions occurring in the application, thereby obtaining the second application code, includes: Identify the visual controls to be used for anomaly testing; Based on the identified visual control, determine the target class associated with the exception test of the visual control; Based on the identified visual control, determine the target function of the target class associated with the anomaly test of the visual control; Based on the anomaly, the relative insertion position of the anomaly triggering code with respect to the objective function is determined.

5. The method for encapsulating applications according to claim 4, characterized in that, The relative insertion positions include those before and after the objective function, respectively.

6. The method for encapsulating applications according to claim 4, characterized in that, The objective function is a function associated with the visual control passing size information to the parent control.

7. The method for encapsulating applications according to claim 6, characterized in that, The exception triggering code is used to generate a random delay based on a random seed when it is executed.

8. A testing method for an application, characterized in that, include: An application installation package for testing is obtained by packaging an application using the packaging method for an application according to any one of claims 1 to 7; Install the application installation package in the terminal to obtain the installed application; The installed application is tested to obtain the test results.

9. The testing method for an application according to claim 8, characterized in that, The testing of the installed application includes: Perform one or more given manual test actions on the terminal where the application is installed.

10. The testing method for an application according to claim 8, characterized in that, The testing of the installed application includes: An automated test script is loaded and executed by a terminal that has the application installed to automatically perform one or more automated test actions, wherein the automated test script records the one or more automated test actions and their execution time and execution order.

11. The testing method for an application according to any one of claims 8 to 10, characterized in that... ; The testing of the installed application includes: Trigger the creation of the visual control; In response to the triggering of the creation of the visual control, the target class is filtered out from all classes in the application by querying the class name; In response to the triggering of the creation of the visual control, the target function is filtered out in the target class by function name query; Based on the relative insertion position, the exception triggering code and the target function of the target class are executed accordingly.

12. The testing method for an application according to any one of claims 8 to 10, characterized in that... ; The testing of the installed application includes: The creation of the visual control is triggered multiple times; In response to each triggering of the creation of the visual control, the visual control passes its size information to its parent control; The delay is randomly generated by the exception triggering code, thereby randomly delaying or not delaying the transmission of the size information; The parent control allocates drawing space for the visual control; The visualization control is drawn based on the drawing space; In at least one of the triggers that create the visualization control, the delay in the random generation of the exception trigger code ensures that the transmission of the size information is completed after the allocation of the drawing space or the drawing of the visualization control.

13. An electronic device, characterized in that, include: A processor and a memory storing a computer program, the processor being configured to implement the method according to any one of claims 1 to 12 when running the computer program.

14. A storage medium, characterized in that, The storage medium stores a computer program configured to be executed to implement the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Software test method and system

    CN104834590A

  • Application program test method, device and system

    CN105607992A

  • Fault-tolerant consensus mechanism test method and device, storage medium and computer equipment

    CN110868337A