Instruction execution method and apparatus, computer device, storage medium, and computer program product

By building an isolated target test environment in mobile device automated testing and executing atomic operation instructions using a predefined set of mapping relationships, the problem of poor test flexibility is solved, and efficient and stable automated testing results are achieved.

CN122432032APending Publication Date: 2026-07-21CHONGQING JINKANG NEW ENERGY VEHICLE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING JINKANG NEW ENERGY VEHICLE CO LTD
Filing Date
2026-04-07
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing automated testing software for mobile devices cannot dynamically build test sandboxes that adapt to complex scenarios, nor can it isolate the test process from the application process, resulting in poor testing flexibility.

Method used

A method for executing instructions is provided. This method receives the atomic operation instructions to be tested from the control terminal, detects whether there is an isolated target test environment on the device, determines the target atomic method using a predefined set of mapping relationships, executes the instructions in the target test environment, and returns the execution results. This achieves efficient, stable, and decoupled remote execution of atomic instructions.

Benefits of technology

It enhances the flexibility and efficiency of automated testing, avoids interference with equipment stability, and provides high-throughput, low-latency, and secure underlying execution support for large-scale distributed automated testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122432032A_ABST
    Figure CN122432032A_ABST
Patent Text Reader

Abstract

The application relates to an instruction execution method and device, a computer device, a storage medium and a computer program product. The method comprises the following steps: receiving a to-be-tested atomic operation instruction of a control end; the to-be-tested atomic operation instruction is obtained based on a test case; when it is detected that a target test environment isolated from the device end exists, an atomic operation type to be tested carried by the to-be-tested atomic operation instruction is acquired; the target test environment is a preset test framework independent of an operating system of the device end; a target atomic method corresponding to the atomic operation type to be tested is determined according to a predefined mapping relationship set; the predefined mapping relationship set comprises at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method; the target atomic method is executed in the target test environment, an execution result of the to-be-tested atomic operation instruction is obtained, and the execution result is encapsulated and returned to the control end. The method can improve the test flexibility of remote instructions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of automated testing technology, and in particular to an instruction execution method, apparatus, computer equipment, storage medium, and computer program product. Background Technology

[0002] With the popularization and development of mobile devices, the application iteration cycle of mobile devices continues to shorten, and the demand for compatibility testing of multiple terminals and multiple versions has surged. Automated testing of mobile devices has become a core technical means to ensure application quality and reduce testing costs.

[0003] Most existing mobile device automated testing software is based on the device system's native testing framework (such as AndroidJUnitRunner, a test runner provided by the Android system) to perform automated testing. For example, AndroidJUnitRunner creates test environments according to fixed logic and binds test processes and application processes to execute test cases. However, AndroidJUnitRunner cannot dynamically build test sandboxes adapted to complex scenarios, nor can it isolate test processes and application processes, resulting in poor testing flexibility. Summary of the Invention

[0004] Based on this, this application addresses the aforementioned technical problems by providing an instruction execution method, apparatus, computer device, computer-readable storage medium, and computer program product that can at least improve testing flexibility.

[0005] Firstly, this application provides an instruction execution method, including:

[0006] Receive the atomic operation instruction to be tested from the control terminal; the atomic operation instruction to be tested is generated based on test cases;

[0007] When an isolated target test environment is detected on the device, the type of the atomic operation to be tested carried by the atomic operation instruction to be tested is obtained; the target test environment is a preset test framework that is independent of the operating system on the device.

[0008] The target atomic method corresponding to the atomic operation type to be tested is determined based on a predefined set of mapping relationships; the predefined set of mapping relationships includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method.

[0009] The target atomic method is executed in the target test environment to obtain the execution result of the atomic operation instruction under test, and the execution result is encapsulated and returned to the control terminal.

[0010] The above-described instruction execution method has at least the following beneficial effects: It receives the atomic operation instructions to be tested generated based on test cases, and after detecting the existence of an isolated target test environment on the device that is independent of the operating system's preset framework, it quickly parses the operation type carried by the instruction; then, based on a predefined mapping relationship set, it accurately locates and calls the corresponding pre-compiled atomic method to complete the instruction execution in the isolated environment; finally, it encapsulates the execution result and returns it to the control end. By constructing an independent target test environment and establishing a standardized mapping between atomic operation types and pre-compiled atomic methods, it achieves an efficient, stable, and decoupled remote execution mechanism for atomic instructions; it also utilizes the pre-compiled mapping mechanism to eliminate runtime method parsing overhead, significantly improving the response speed and execution efficiency of the atomic operation instructions to be tested; simultaneously, the isolated target test environment ensures the decoupling of atomic operations from the system's native test framework, avoiding potential interference with device stability during test execution, providing high-throughput, low-latency, and secure underlying execution support for large-scale distributed automated testing, and improving the overall efficiency and flexibility of automated testing.

[0011] In an optional embodiment of the first aspect, before detecting the existence of an isolated target test environment on the device side, the method further includes:

[0012] If the target test environment is not detected on the device, an isolated test instance to be set is created on the device through a reflection mechanism; the test instance to be set is independent of the preset instance of the preset test framework on the device.

[0013] Through the reflection mechanism, the hidden class for interface automation services in the operating system is accessed and instantiated to obtain an object instance of the hidden class.

[0014] Based on the object instance, establish a connection between the test instance to be set and the interface automation service to obtain a custom test instance;

[0015] The context information of the application on the device is injected into the custom test instance through the reflection mechanism to obtain a custom test environment; the custom test environment includes resource access permissions and function execution permissions on the device.

[0016] The connection method of the target interface is invoked to activate the custom test environment and obtain the target test environment; the target interface is used to interact with the interface automation service.

[0017] In this embodiment, at least the following beneficial effects are achieved: When the target test environment is detected to be absent on the device, a test instance independent of the preset test framework is created using reflection, ensuring decoupling and isolation between the target test environment and the native framework. Then, a hidden class for interface automation services in the operating system is accessed and instantiated using reflection, establishing a low-level connection between the test instance and the automation service. Next, the context information of the device application is injected, granting the custom test environment full resource access and function execution permissions. Finally, the target interface is called to activate the environment, achieving stable interaction with the automation service. This not only effectively solves the problem of poor testing flexibility in the native device test environment but also avoids interference with the original system framework through isolation, significantly improving test compatibility and security. Simultaneously, the target test environment is granted full application context permissions, enabling the atomic operation instructions under test to realistically simulate user operations, providing flexible, efficient, and reusable infrastructure support for automated testing of mobile device applications.

[0018] In an optional embodiment of the first aspect, before determining the target atomic method corresponding to the atomic operation instruction to be tested according to a predefined set of mapping relationships, the method further includes:

[0019] The native methods of the predefined atomic operation types are pre-compiled to obtain the predefined atomic operation methods.

[0020] Establish a mapping relationship between the predefined atomic operation types and the predefined atomic operation methods to obtain the predefined mapping relationship set.

[0021] In this embodiment, at least the following beneficial effects are achieved: by pre-compiling the local methods of predefined atomic operation types, predefined atomic operation methods that can be directly called are generated in advance, and a standardized mapping relationship between them and atomic operation types is established. This constructs a set of efficient and reusable predefined mapping relationships, which pre-compiles and parses the work that originally needed to be repeated at runtime, significantly reduces the dynamic calculation overhead in the test execution phase, and significantly improves the response speed and execution efficiency of atomic operation calls. It is especially suitable for large-scale automated testing scenarios, which can effectively reduce the runtime load of the target test environment, thereby improving the execution efficiency of the atomic operation instructions under test.

[0022] In an optional embodiment of the first aspect, obtaining the type of atomic operation to be tested carried by the atomic operation instruction to be tested includes:

[0023] The atomic operation instruction to be tested is parsed to obtain the operation field in the atomic operation instruction to be tested.

[0024] Based on the operation field, the type of atomic operation to be tested of the atomic operation instruction to be tested is obtained.

[0025] In this embodiment, at least the following beneficial effects are achieved: by performing instruction parsing processing on the atomic operation instruction to be tested, the operation field and parameter field in the atomic operation instruction to be tested can be accurately extracted, and the type of atomic operation to be tested corresponding to the atomic operation instruction to be tested can be determined based on the operation field. This realizes the structured parsing of atomic operation instructions and the automatic identification of operation types, improves the accuracy and efficiency of instruction parsing, and provides reliable data support for the subsequent execution and testing process of atomic operations.

[0026] In an optional embodiment of the first aspect, executing the target atomic method in the target testing environment to obtain the execution result of the atomic operation instruction under test includes:

[0027] The parameters to be executed, corresponding to the parameter fields carried in the atomic operation instruction to be tested, are input into the target atomic method to obtain the atomic method to be executed.

[0028] The atomic method to be executed is executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested.

[0029] In this embodiment, at least the following beneficial effects are achieved: the parameters to be executed are input into the target atomic method to form an atomic method with complete parameters, avoiding the overhead of runtime parameter parsing and type conversion; then, the method is executed in a target test environment independent of the system's native framework, ensuring that the instruction execution process is close to the efficiency of the operating system's native API call, without interfering with device stability and the preset test framework. By directly injecting parameters and quickly calling pre-compiled atomic methods, the processing path from string instructions to function execution is greatly shortened, significantly improving the response speed of the atomic operation instructions under test.

[0030] In an optional embodiment of the first aspect, the type of atomic operation to be tested includes a progress identification type; the target atomic method corresponding to the progress identification type is used to indicate the progress value in the device interface.

[0031] The step of executing the atomic method to be executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested also includes:

[0032] Based on the target test environment, obtain the current screenshot of the device.

[0033] The current screenshot is converted from the first color space to the second color space to obtain the converted image of the current screenshot;

[0034] Based on the second color space range preset for the progress bar color, the converted image is processed to extract the pixel region of the progress bar to obtain the progress bar filling region in the converted image.

[0035] The candidate progress value of the converted image is obtained based on the pixel ratio between the progress bar filled area and the overall progress bar area in the converted image.

[0036] If the verification result for the candidate progress value is detected as passed, then the candidate progress value is set as the execution result.

[0037] In this embodiment, at least the following beneficial effects are achieved: A screenshot of the current screen of the device is acquired in an isolated target test environment and converted from the original first color space to a preset second color space to eliminate lighting interference and highlight the hue characteristics of the progress bar; then, based on a preset color range for the progress bar color, the progress bar filling area in the converted image is accurately extracted; by calculating the pixel ratio between the filling area and the overall area, candidate progress values ​​are quantified; finally, after successful verification, the candidate progress values ​​are returned as the instruction execution result. A progress value recognition mechanism based on color space is constructed through atomic operations targeting progress recognition types, effectively avoiding the misjudgment problem of traditional OCR recognition methods when facing complex backgrounds and changes in light and shadow, thereby improving the intelligence level and recognition accuracy of interface progress bar perception.

[0038] Secondly, this application also provides an instruction execution device, comprising:

[0039] The instruction receiving module is used to receive the atomic operation instruction to be tested from the control terminal; the atomic operation instruction to be tested is generated based on test cases;

[0040] The instruction parsing module is used to obtain the type of atomic operation to be tested carried by the atomic operation instruction to be tested when an isolated target test environment is detected on the device side; the target test environment is independent of the preset test framework of the operating system on the device side.

[0041] The method determination module is used to determine the target atomic method corresponding to the atomic operation type to be tested based on a predefined mapping relationship set; the predefined mapping relationship set includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method;

[0042] The method invocation module is used to execute the target atomic method in the target test environment, obtain the execution result of the atomic operation instruction to be tested, and encapsulate the execution result and return it to the control terminal.

[0043] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described above.

[0044] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described above.

[0045] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in any of the above aspects.

[0046] Regarding the beneficial effects of any of the technical solutions in the second to fifth aspects mentioned above, refer to the beneficial effects of the corresponding technical solutions in the first aspect; repeated examples will not be listed here. Attached Figure Description

[0047] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a schematic diagram illustrating an optional application environment for the instruction execution method in one embodiment.

[0049] Figure 2 This is a schematic diagram of an optional instruction execution method in one embodiment;

[0050] Figure 3 This is a schematic diagram of an optional process for constructing a target test environment in one embodiment;

[0051] Figure 4 This is a schematic diagram illustrating the process of constructing a target test environment using a reflection mechanism in one embodiment;

[0052] Figure 5 This is a schematic diagram of the atomic operation classification in one embodiment;

[0053] Figure 6 This is a schematic diagram of a progress bar recognition process based on color space in one embodiment;

[0054] Figure 7 This is a schematic diagram of another optional flowchart of the instruction execution method in one embodiment;

[0055] Figure 8This is a timing flowchart of an instruction execution method in one embodiment;

[0056] Figure 9 This is a schematic diagram of the overall architecture of the instruction execution method in one embodiment;

[0057] Figure 10 This is a schematic diagram of an optional structure of an instruction execution device in one embodiment;

[0058] Figure 11 This is a schematic diagram of an optional internal structure of a computer device in one embodiment. Detailed Implementation

[0059] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of this application.

[0060] The terms "first," "second," etc., used in this application may be used to describe various elements, but these elements are not limited by these terms. These terms are used only to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0061] The instruction execution method provided in this application embodiment can be applied to, for example, Figure 1 The application environment is shown. Control terminal 101 communicates with device terminal 102 via a network. A data storage system can store the data that device terminal 102 needs to process. The data storage system can be integrated locally on device terminal 102 or placed in the cloud or on another network server. Device terminal 102 receives the atomic operation instruction to be tested from control terminal 101; the atomic operation instruction to be tested is generated based on test cases; when an isolated target test environment is detected on the device terminal, the type of atomic operation to be tested carried by the atomic operation instruction to be tested is obtained; the target test environment is a preset test framework independent of the device terminal's operating system; according to a predefined mapping relationship set, the target atomic method corresponding to the atomic operation type to be tested is determined; the predefined mapping relationship set includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method; in the target test environment, the atomic operation instruction to be tested is executed based on the target atomic method, the execution result of the atomic operation instruction to be tested is obtained, and the execution result is encapsulated and returned to control terminal 101.

[0062] In practical applications, the control terminal 101 can be a platform for testers to develop and manage test cases; the control terminal 101 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The device terminal 102 can be a mobile device (or the processor of a mobile device); mobile devices include, but are not limited to, various personal computers, laptops, smartphones, tablets, and Internet of Things devices (such as smart in-vehicle devices).

[0063] In one exemplary embodiment, such as Figure 2 As shown, an instruction execution method is provided, which is applied to... Figure 1 Taking device 102 as an example, the explanation includes the following steps S201 to S204. Wherein:

[0064] Step S201: Receive the atomic operation instruction to be tested from the control terminal; the atomic operation instruction to be tested is generated based on the test cases.

[0065] Here, the atomic operation instruction to be tested refers to the atomic operation instruction to be tested. An atomic operation instruction is an indivisible, most basic UI (User Interface) interaction instruction.

[0066] Test cases refer to a list of test tasks written to verify UI interaction functions.

[0067] For example, at the control end, test cases for the application under test on the device are converted into a sequence of atomic operation instructions; wherein the sequence of atomic operation instructions contains at least one atomic operation instruction to be tested. The control end transmits the sequence of atomic operation instructions to the device according to the communication network agreed upon with the device. The device then receives the atomic operation instruction to be tested sent by the control end.

[0068] In practical applications, the control end can communicate with the device via HTTP (a transport protocol) and transmit atomic operation instruction sequences using JSON (a data format); it can also use WebSocket (a communication protocol) to achieve long-lived bidirectional communication between the control end and the device and transmit atomic operation instruction sequences using MessagePack (a lightweight binary serialization format); it can also use high-performance RPC (Remote Procedure Call) frameworks such as gRPC (an open-source, high-performance remote procedure call framework) to achieve communication between the control end and the device and transmit atomic operation instruction sequences using Protocol Buffers (a binary serialization format); it can also use IoT protocols such as MQTT (Message Queuing Telemetry Transport) to achieve communication between the control end and the device; of course, other methods can also be used to achieve communication between the control end and the device, or other data formats can be used to transmit atomic operation instruction sequences.

[0069] Step S202: When an isolated target test environment is detected on the device side, the type of the atomic operation to be tested carried by the atomic operation instruction to be tested is obtained; the target test environment is a preset test framework of the operating system independent of the device side.

[0070] The preset test framework refers to the native test runner provided by the device's operating system.

[0071] For example, if this is the first time testing is performed on the current device, a target test environment needs to be built first. This is because the atomic operation interface cannot be directly used in the device's operating system (e.g., Android), so a test environment needs to be built before atomic operations can be executed. Furthermore, to decouple the dependency on the device's pre-defined test framework and address the technical shortcomings of the pre-defined test framework—namely, fixed test operations and the inability to perform parallel testing—an independent target test environment can be built on the device, allowing for parallel testing of atomic operation instruction sequences within that environment.

[0072] If this is not the first time the test is being performed on the current device, it means that the target test environment has already been built on the device. Therefore, there is no need to rebuild the target test environment again. You can proceed to the next step of the instruction execution method, which is to obtain the type of atomic operation to be tested carried by the atomic operation instruction to be tested. For example, you can parse each atomic operation instruction to be tested in the atomic operation instruction sequence to obtain the type of atomic operation to be tested carried by each atomic operation instruction to be tested.

[0073] Step S203: Determine the target atomic method corresponding to the atomic operation type to be tested based on the predefined mapping relationship set; the predefined mapping relationship set includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method.

[0074] The predefined mapping set can be viewed as an instruction (atomic operation type) - method mapping table, or as a predefined method library.

[0075] Here, predefined atomic operation types refer to the types of atomic operations that are defined in advance. Precompiled atomic methods refer to precompiled native methods.

[0076] The atomic operation instruction to be tested is mapped to a local method call. For example, after parsing the atomic operation type to be tested from the atomic operation instruction to be tested, the predefined mapping relationship set is queried according to the atomic operation type to be tested to obtain the target atomic method corresponding to the atomic operation type to be tested.

[0077] In addition, an executor interface containing predefined atomic operation methods can be defined. Classes implementing the executor interface are created for each predefined atomic operation type, and these classes are instantiated to obtain executor instances corresponding to each predefined atomic operation type. After parsing the atomic operation type to be tested from the instruction to be tested, the corresponding executor instance is selected based on the atomic operation type, and the precompiled atomic methods in that executor instance are called through dynamic proxy or factory pattern.

[0078] Step S204: Execute the target atomic method in the target test environment, obtain the execution result of the atomic operation instruction to be tested, encapsulate the execution result and return it to the control terminal.

[0079] For example, since the target atomic method is a pre-compiled native method, the control terminal can directly call the target atomic method, skipping the test script parsing or additional installation steps. After parsing the parameters to be executed from the atomic operation instruction to be tested, the parameters are input into the target atomic method and executed in the target test environment. After execution, the execution result (such as success, failure, captured data, or image analysis results) is encapsulated to obtain the encapsulated execution result; according to the communication network agreed with the control terminal, the encapsulated execution result is returned to the control terminal.

[0080] In the above instruction execution method, the system receives the atomic operation instruction to be tested generated based on test cases. After detecting the existence of an isolated target test environment on the device side that is independent of the operating system's preset framework, it quickly parses the operation type carried by the instruction. Then, based on a predefined mapping relationship set, it accurately locates and calls the corresponding pre-compiled atomic method to complete the instruction execution in the isolated environment. Finally, it encapsulates the execution result and returns it to the control end. By constructing an independent target test environment and establishing a standardized mapping between atomic operation types and pre-compiled atomic methods, it achieves an efficient, stable, and decoupled remote execution mechanism for atomic instructions. It also utilizes the pre-compiled mapping mechanism to eliminate the runtime method parsing overhead, significantly improving the response speed and execution efficiency of the atomic operation instruction to be tested. At the same time, the isolated target test environment ensures the decoupling of atomic operations from the system's native test framework, avoiding potential interference with device stability during test execution. It provides high-throughput, low-latency, and secure underlying execution support for large-scale distributed automated testing, improving the overall efficiency and flexibility of automated testing.

[0081] In an exemplary embodiment, before detecting the existence of an isolated target test environment on the device side in step S202 above, such as Figure 3 As shown, the steps for building the target test environment are provided, including:

[0082] Step S301: If the target test environment is not detected on the device, an isolated test instance to be set is created on the device through reflection mechanism; the test instance to be set is independent of the preset instance of the preset test framework on the device.

[0083] In this context, "test instance to be set" refers to an empty test instance that has not been set. A test instance can be understood as a tool that can operate and execute test functions.

[0084] For example, if the target test environment is not detected on the device, it means that this is the first time the test is executed on the current device. Then, the test instance constructor defined by the device's operating system (such as Android) can be called through the reflection mechanism to create an independent, isolated, and pre-defined test instance that does not depend on the device's pre-defined test framework.

[0085] For example, Figure 4This diagram illustrates the process of building the target test environment using reflection. On the device side, a new empty instance of `Instrumentation` is dynamically created by calling the constructor of the `Instrumentation` class defined by the Android system. This new `Instrumentation` instance is the test instance to be set up. The `Instrumentation` instance is a tool defined by Android for monitoring and controlling the interaction between the application and the system during testing. However, it runs in the same process as the application under test and is not an interface for cross-process communication. By not using preset instances provided by preset testing frameworks (such as `AndroidJUnitRunner`), the control of the target test environment by preset testing frameworks is effectively eliminated.

[0086] Step S302: Using reflection, access and instantiate the hidden class for the interface automation service in the operating system to obtain an object instance of the hidden class.

[0087] For example, by using reflection to bypass access restrictions on the device's operating system, the hidden class for the UI automation service (i.e., UI automation service) in the device's operating system is found, and the constructor of the hidden class is called to create an object instance of the hidden class.

[0088] The hidden class object instance can be seen as a "communication intermediary" between the test instance to be set and the interface automation service on the device. Only by binding the object instance to the test instance to be set can the test instance to be set establish a connection with the interface automation service on the device and have the ability to perform underlying UI operations.

[0089] For example, the Android system marks some core and sensitive classes as "hidden" (such as the UiAutomationConnection class). Regular developers cannot directly create (new) this hidden class or access its methods or constructors (the system implements access restrictions to prevent unauthorized calls to underlying services). Therefore, by using reflection, one can access the hidden class in the operating system that provides UI automation services, call the constructor of this hidden class, and generate a usable object instance.

[0090] Step S303: Based on the object instance, establish a connection between the test instance to be set and the interface automation service to obtain the custom test instance.

[0091] For example, by using reflection, the object instance is set into the internal member variable of the test instance to be set, so as to establish the underlying connection between the test instance to be set and the interface automation service, thereby obtaining the customized test instance after setting.

[0092] like Figure 4 As shown, continuing with the Instrumentation instance as the test instance to be set, you can set the object instance of a hidden class (such as the UiAutomationConnection class) into the internal member variable (such as mUiAutomationConnection) of the Instrumentation instance, thereby establishing a low-level connection with the UI automation service of the Android system.

[0093] Step S304: Using reflection, the context information of the application on the device is injected into the custom test instance to obtain a custom test environment; the custom test environment includes access permissions to the device's resources and permissions to execute functions.

[0094] For example, the application context information (App Context) on the device is injected into the internal context field of a custom test instance through reflection to obtain a custom test environment with resource access permissions and function execution permissions.

[0095] The internal context field of a custom test instance can be either the mInstrContext field or the mAppContext field of the Instrumentation instance.

[0096] The `mInstrContext` field is the context of the Instrumentation instance itself. It represents the context of the test or instrumentation process and is typically associated with the APK (Android Package Kit) running the test, rather than the application being tested. `mAppContext` is the context of the target application (Application under test). It points to the Application instance of the application being developed or tested. The `getTargetContext()` method of the Instrumentation class returns this object, making it crucial for interacting with the target application. This context needs to be injected via reflection to associate the Instrumentation's own context with the running APK, thus creating an isolated environment.

[0097] Step S305: Call the connection method of the target interface to activate the custom test environment and obtain the target test environment; the target interface is used to interact with the interface automation service.

[0098] The target interface is the core interface provided by the device for interacting with the UI automation service. It encapsulates cross-process and cross-application UI operation privileges. For example, the target interface could be the UiAutomation class.

[0099] For example, by calling the Connect method of the target interface through an object instance in the custom test environment, the custom test environment is activated, resulting in a completely independent target test environment that can perform UI interactions and queries.

[0100] The target test environment is decoupled from any pre-defined test framework (or test runner) thread.

[0101] In this embodiment, when the target test environment is detected to be absent on the device, a test instance independent of the preset test framework is created using reflection, ensuring decoupling and isolation between the target test environment and the native framework. Then, a hidden class for UI automation services in the operating system is accessed and instantiated using reflection, establishing a low-level connection between the test instance and the automation service. The context information of the device application is then injected into this instance, granting the custom test environment full resource access and function execution permissions. Finally, the target interface is called to activate the environment, achieving stable interaction with the automation service. This not only effectively solves the problem of poor testing flexibility in the native device test environment but also avoids interference with the original system framework through isolation, significantly improving test compatibility and security. Simultaneously, the target test environment is granted full application context permissions, enabling the atomic operation instructions under test to realistically simulate user operations, providing flexible, efficient, and reusable infrastructure support for automated testing of mobile device applications.

[0102] In an exemplary embodiment, before determining the target atomic method corresponding to the atomic operation type to be tested based on the predefined mapping relationship set in step S203 above, the method further includes: pre-compiling the local method of the predefined atomic operation type to obtain the predefined atomic operation method; and establishing the mapping relationship between the predefined atomic operation type and the predefined atomic operation method to obtain the predefined mapping relationship set.

[0103] For example, the interface interaction and verification logic on the device side can be encapsulated into atomic operations to obtain predefined atomic operation types, local methods of the predefined atomic operation types can be created, and the local methods can be pre-compiled to obtain predefined atomic operation methods; a mapping relationship between predefined atomic operation types and predefined atomic operation methods can be established to obtain a set of predefined mapping relationships.

[0104] Figure 5The diagram illustrates the structure of atomic operations. Predefined atomic operation types can be broadly categorized into three main types: device control, control interaction, and verification criteria. Each predefined atomic operation type can be further subdivided into at least one sub-category. For example, (a) device control types include, but are not limited to: wakeup (wakeUp) and press key (pressKeyCode); (b) control interaction types include, but are not limited to: click object (clickObj), scroll object to center (scrollObjCenter), and flick to end (flingToEnd); (c) verification criteria types include, but are not limited to: check text (checkTxt) and progress bar recognition (imageProgress).

[0105] In this embodiment, by pre-compiling the local methods of predefined atomic operation types, predefined atomic operation methods that can be directly called are generated in advance, and a standardized mapping relationship between them and atomic operation types is established. This constructs a set of efficient and reusable predefined mapping relationships, which pre-compiles and parses the work that originally needed to be repeated at runtime, significantly reducing the dynamic calculation overhead in the test execution phase and significantly improving the response speed and execution efficiency of atomic operation calls. It is especially suitable for large-scale automated testing scenarios, which can effectively reduce the runtime load of the target test environment, thereby improving the execution efficiency of the atomic operation instructions under test.

[0106] In an exemplary embodiment, step S202 above, obtaining the type of atomic operation to be tested carried by the atomic operation instruction to be tested, includes the following: performing instruction parsing processing on the atomic operation instruction to be tested to obtain the operation field and parameter field in the atomic operation instruction to be tested; and obtaining the type of atomic operation to be tested of the atomic operation instruction to be tested based on the operation field.

[0107] The operation field describes the operation type of the atomic operation instruction to be tested.

[0108] For example, the device can perform instruction parsing processing on the atomic operation instruction to be tested according to the communication protocol and data transmission format between the device and the control terminal to obtain the instruction string corresponding to the atomic operation instruction to be tested; the instruction string contains an operation field and a parameter field; then, based on the operation field, the type of atomic operation to be tested can be read from the instruction string; based on the parameter field, the parameters to be executed can be read from the instruction string.

[0109] For example, assuming the atomic operation instruction to be tested is in the form of an HTTP request, we can first verify the validity of the request based on the HTTP request header. Then, we can parse the JSON string of the atomic operation instruction to be tested from the HTTP message. For example, the parsed JSON string could be {"action": "scrollObjCenter", "params": {"id": "list_view"}}, where "action" represents the operation field, "scrollObjCenter" represents the type of atomic operation to be tested, "params" represents the parameter field, and {"id": "list_view"} represents the parameter to be executed.

[0110] In this embodiment, by performing instruction parsing on the atomic operation instruction to be tested, the operation field and parameter field in the atomic operation instruction to be tested can be accurately extracted, and the type of atomic operation to be tested corresponding to the atomic operation instruction to be tested can be determined based on the operation field. This realizes the structured parsing of atomic operation instructions and the automatic identification of operation types, improves the accuracy and efficiency of instruction parsing, and provides reliable data support for the subsequent execution and testing process of atomic operations.

[0111] In an exemplary embodiment, step S204 above, executing the target atomic method in the target test environment to obtain the execution result of the atomic operation instruction under test, includes the following: inputting the parameter field corresponding to the parameter to be executed carried in the atomic operation instruction under test into the target atomic method to obtain the atomic method to be executed; executing the atomic method to be executed in the target test environment to obtain the execution result of the atomic operation instruction under test.

[0112] For example, the parameters to be executed corresponding to the parameter fields are input into the target atomic method to obtain the atomic method to be executed; the atomic method to be executed is executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested.

[0113] Understandably, a method is a higher-level encapsulation and entry point for an API (Application Programming Interface). Calling a pre-compiled atomic method (such as an atomic method to be executed) is essentially calling the operating system's native API, achieving a direct and efficient call from string instructions to the native API.

[0114] In this embodiment, the parameters to be executed are input into the target atomic method to form an atomic method with complete parameters, avoiding the overhead of runtime parameter parsing and type conversion. Then, the method is executed in a target test environment independent of the system's native framework, ensuring that the instruction execution process is close to the efficiency of the operating system's native API call, without interfering with device stability and the preset test framework. By directly injecting parameters and quickly calling pre-compiled atomic methods, the processing path from string instructions to function execution is greatly shortened, significantly improving the response speed of the atomic operation instructions under test.

[0115] In an exemplary embodiment, the type of atomic operation to be tested includes a progress recognition type; the target atomic method corresponding to the progress recognition type is used to indicate the progress value in the device interface. Executing the atomic method to be executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested further includes: acquiring a current screenshot of the device based on the target test environment; converting the current screenshot from a first color space to a second color space to obtain a converted image of the current screenshot; performing pixel region extraction processing on the converted image for the progress bar according to a preset second color space range for the progress bar color to obtain a progress bar filled area in the converted image; obtaining a candidate progress value of the converted image based on the pixel ratio between the progress bar filled area and the overall progress bar area in the converted image; and setting the candidate progress value as the execution result if the verification result for the candidate progress value is passed.

[0116] The entire progress bar area refers to the complete visual area on the interface that displays the progress indicator; it encompasses the entire space within the progress bar's boundaries. Regardless of the task's progress, the extent of the entire progress bar area remains constant.

[0117] The progress bar filled area refers to the visual sub-area within the overall progress bar area, used to intuitively display the progress of the task. The size (usually the width) of the progress bar filled area changes dynamically with the proportion of task completion.

[0118] The first color space refers to the original color space of the current screenshot. The second color space refers to the specified color space.

[0119] Assume the type of the atomic operation to be tested is Figure 5 The progress bar identified by `imageProgress()` then identifies the corresponding target atomic method, which performs quantization analysis of the progress value on the device interface based on color space. For example, Figure 6This is a flowchart illustrating the process of progress bar recognition based on color space. First, a screenshot interface is called using the target testing environment to capture the current screenshot on the device. Then, the color space of the current screenshot is converted from a first color space (e.g., RGB, red, blue, green) to a second color space (e.g., HSV, hue, saturation, brightness) to obtain the converted image of the current screenshot. This eliminates lighting interference in the image and highlights the hue characteristics of the progress bar. Based on the preset second color space range for the progress bar color, pixel region extraction processing is performed on the converted image to obtain the progress bar filling area. For example, if the HSV hue range corresponding to the blue progress bar is [0.55, 0.65], then the pixel region of the blue progress bar, i.e., the progress bar filling area, can be identified in the converted image based on the hue of the second color space of the converted image. Alternatively, the entire progress bar area in the converted image can be determined using a target recognition algorithm or preset progress bar position information. The number of pixels within the filled area of ​​the progress bar (labeled as the first pixel count) and the total number of pixels within the entire progress bar area (labeled as the second pixel count) are counted. The ratio between the first and second pixel counts is calculated to obtain the pixel count ratio. Based on the correspondence between the pixel count ratio and the progress value, candidate progress values ​​for the converted image are determined (the candidate progress value ranges from 0% to 100%). For example, if the pixel count ratio * 100% = progress value, and the pixel count ratio is 0.85, then the progress value is 85%. The difference between the candidate progress value and the expected progress value is calculated. If this difference is within a preset tolerance range (e.g., 0.05 ≤ δ ≤ 0.2, where δ represents the difference), the verification result for the candidate progress value is considered successful; otherwise, the verification result is considered unsuccessful. If the verification result for the candidate progress value is detected as successful, the candidate progress value is set as the execution result of the progress bar recognition.

[0120] In this embodiment, a screenshot of the current screen of the device is acquired in an isolated target test environment and converted from the original first color space to a preset second color space to eliminate lighting interference and highlight the hue features of the progress bar. Then, based on the preset color range for the progress bar color, the progress bar filling area in the converted image is accurately extracted. By calculating the ratio of the number of pixels between the filling area and the overall area, a candidate progress value is quantified. Finally, after verification, the candidate progress value is returned as the instruction execution result. A progress value recognition mechanism based on color space is constructed through atomic operations for progress recognition type. By using HSV color space analysis to replace the traditional RGB pixel comparison, methods such as imageProgress() can more accurately quantify the state of dynamic UI elements (such as progress bars), effectively reducing recognition errors. The configurable tolerance threshold also makes it adaptable to complex scenarios such as low light and dynamic backgrounds, improving the robustness and reliability of the test.

[0121] In one embodiment, such as Figure 7 As shown, another instruction execution method is provided, which can be applied to... Figure 1 Taking the device side as an example, the explanation includes the following steps:

[0122] Step S701: Receive the atomic operation instruction to be tested from the control terminal; the atomic operation instruction to be tested is generated based on the test cases.

[0123] The system detects whether an isolated target test environment exists on the device side; if no target test environment is detected on the device side, it proceeds to step S702; if an isolated target test environment is detected on the device side, it proceeds to step S707.

[0124] Step S702: If the target test environment is not detected on the device, an isolated test instance to be set is created on the device through reflection mechanism; the test instance to be set is independent of the preset instance of the preset test framework on the device.

[0125] Step S703: Using reflection, access and instantiate the hidden class for the interface automation service in the operating system to obtain an object instance of the hidden class.

[0126] Step S704: Based on the object instance, establish a connection between the test instance to be set and the interface automation service to obtain the custom test instance.

[0127] Step S705: Using reflection, the context information of the application on the device is injected into the custom test instance to obtain a custom test environment; the custom test environment includes access permissions to the device's resources and permissions to execute functions.

[0128] Step S706: Call the connection method of the target interface to activate the custom test environment and obtain the target test environment; the target interface is used to interact with the interface automation service.

[0129] Step S707: Perform instruction parsing processing on the atomic operation instruction to be tested to obtain the operation field in the atomic operation instruction to be tested; based on the operation field, obtain the atomic operation type to be tested of the atomic operation instruction to be tested.

[0130] Step S708: Determine the target atomic method corresponding to the atomic operation type to be tested based on the predefined mapping relationship set; the predefined mapping relationship set includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method.

[0131] Step S709: Input the parameters to be executed corresponding to the parameter fields carried in the atomic operation instruction to be tested into the target atomic method to obtain the atomic method to be executed; execute the atomic method to be executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested, and encapsulate the execution result and return it to the control terminal.

[0132] The above-described instruction execution method achieves the following beneficial effects: It receives atomic operation instructions generated based on test cases, and upon detecting the existence of an isolated target test environment on the device that is independent of the operating system's preset framework, it quickly parses the operation type carried by the instruction; then, based on a predefined mapping set, it accurately locates and calls the corresponding pre-compiled atomic method, completing the instruction execution in the isolated environment; finally, it encapsulates the execution result and returns it to the control end. By constructing an independent target test environment and establishing a standardized mapping between atomic operation types and pre-compiled atomic methods, it achieves an efficient, stable, and decoupled remote execution mechanism for atomic instructions; it also utilizes the pre-compiled mapping mechanism to eliminate runtime method parsing overhead, significantly improving the response speed and execution efficiency of the atomic operation instructions under test; simultaneously, the isolated target test environment ensures the decoupling of atomic operations from the system's native test framework, avoiding potential interference with device stability during test execution, providing high-throughput, low-latency, and secure underlying execution support for large-scale distributed automated testing, and improving the overall efficiency and flexibility of automated testing.

[0133] To more clearly illustrate the instruction execution method provided in the embodiments of this disclosure, the following specific embodiment will be used to describe the above instruction execution method in detail. For example... Figure 8 and Figure 9 As shown, an instruction execution method, assuming the control end is a cloud server and the device end is a mobile device based on the Android system, specifically includes the following:

[0134] (1) Instruction issuance: The cloud server converts the test case into an atomic operation instruction sequence and issues the JSON format atomic operation instruction sequence to the processor of the specified mobile device via the network (such as HTTP).

[0135] (2) Environment ready: When the device processor receives the first atomic operation instruction or a specific atomic operation instruction, if it detects that the target test environment has not yet been built on the device, it dynamically builds the test environment through the reflection mechanism.

[0136] (3) Parsing and execution: Parse the received JSON format atomic operation instructions (referred to as JSON instructions) in the target test environment to obtain the atomic operation type to be tested and the parameters to be executed; find the target atomic method corresponding to the atomic operation type to be tested through a predefined mapping relationship set (such as the instruction-method mapping table), pass the target atomic method to the parameters to be executed, and then execute it, that is, call the Android system API.

[0137] (4) Result feedback: After execution, the execution result (success, failure, captured data or image analysis result) is encapsulated and returned to the cloud server. For example, if the target atomic method is a progress bar recognition based on color space, then the candidate progress value can be set as the execution result of the progress bar recognition.

[0138] (5) Result storage: The cloud server determines whether the execution result meets the expected result of the test case and saves the execution result and its determination result to the cloud.

[0139] In this embodiment, the following beneficial effects can be achieved: by constructing an independent target testing environment and establishing a standardized mapping between atomic operation types and pre-compiled atomic methods, an efficient, stable, and decoupled remote execution mechanism for atomic instructions is realized; furthermore, by encapsulating UI interaction and verification logic into atomic operations and implementing direct calls from remote JSON instructions to local native methods through an instruction mapping table, the repetitive coding of complex interactions is reduced, and the efficiency of test case development is improved; at the same time, the overhead of script interpretation is also reduced.

[0140] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0141] Based on the same inventive concept, this application also provides an instruction execution apparatus for implementing the instruction execution method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more instruction execution apparatus embodiments provided below can be found in the limitations of the instruction execution method above, and will not be repeated here.

[0142] In one exemplary embodiment, such as Figure 10 As shown, an instruction execution device 1000 is provided, comprising:

[0143] The instruction receiving module 1001 is used to receive the atomic operation instruction to be tested from the control terminal; the atomic operation instruction to be tested is generated based on the test cases.

[0144] The instruction parsing module 1002 is used to obtain the type of atomic operation to be tested carried by the atomic operation instruction to be tested when an isolated target test environment is detected on the device side; the target test environment is a preset test framework of the operating system independent of the device side.

[0145] The method determination module 1003 is used to determine the target atomic method corresponding to the atomic operation type to be tested based on a predefined mapping relationship set; the predefined mapping relationship set includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method.

[0146] The method invocation module 1004 is used to execute the target atomic method in the target test environment, obtain the execution result of the atomic operation instruction to be tested, and encapsulate the execution result and return it to the control terminal.

[0147] In one embodiment, the instruction execution device 1000 further includes an environment construction module, configured to create an isolated test instance to be set on the device via reflection if a target test environment is detected to be absent on the device. The test instance to be set is independent of the preset instance of the preset test framework on the device. The hidden class for the interface automation service in the operating system is accessed and instantiated via reflection to obtain an object instance of the hidden class. Based on the object instance, a connection is established between the test instance to be set and the interface automation service to obtain a custom test instance. The context information of the application on the device is injected into the custom test instance via reflection to obtain a custom test environment. The custom test environment includes resource access permissions and function execution permissions on the device. The connection method of the target interface is called to activate the custom test environment to obtain the target test environment. The target interface is used to interact with the interface automation service.

[0148] In one embodiment, the instruction execution device 1000 further includes a mapping construction module, which is used to precompile local methods of predefined atomic operation types to obtain predefined atomic operation methods; and to establish a mapping relationship between predefined atomic operation types and predefined atomic operation methods to obtain a set of predefined mapping relationships.

[0149] In one embodiment, the instruction parsing module 1002 is further configured to perform instruction parsing processing on the atomic operation instruction to be tested, to obtain the operation field in the atomic operation instruction to be tested; and based on the operation field, to obtain the atomic operation type to be tested of the atomic operation instruction to be tested.

[0150] In one embodiment, the method invocation module 1004 is further configured to input the parameters to be executed corresponding to the parameter fields carried in the atomic operation instruction to be tested into the target atomic method to obtain the atomic method to be executed; and execute the atomic method to be executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested.

[0151] In one embodiment, the instruction execution device 1000 further includes a progress bar recognition module, configured to: acquire a current screenshot of the device based on a target test environment; convert the current screenshot from a first color space to a second color space to obtain a converted image of the current screenshot; perform pixel region extraction processing on the converted image for the progress bar according to a preset second color space range for the progress bar color to obtain a progress bar filling region in the converted image; obtain a candidate progress value of the converted image based on the pixel ratio between the progress bar filling region and the overall progress bar region in the converted image; and if the verification result for the candidate progress value is detected as passed, set the candidate progress value as the execution result.

[0152] Each module in the aforementioned instruction execution device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0153] In one exemplary embodiment, a computer device is provided, which may be a device terminal, and its internal structure diagram may be as follows: Figure 11As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements an instruction execution method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0154] Those skilled in the art will understand that Figure 11 The structure shown is a block diagram of a partial structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.

[0155] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0156] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described method embodiments.

[0157] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0158] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0159] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program mentioned can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0160] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0161] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for executing instructions, characterized in that, The method includes: Receive the atomic operation instruction to be tested from the control terminal; the atomic operation instruction to be tested is generated based on test cases; When an isolated target test environment is detected on the device, the type of the atomic operation to be tested carried by the atomic operation instruction to be tested is obtained; the target test environment is a preset test framework that is independent of the operating system on the device. The target atomic method corresponding to the atomic operation type to be tested is determined based on a predefined set of mapping relationships; the predefined set of mapping relationships includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method. The target atomic method is executed in the target test environment to obtain the execution result of the atomic operation instruction under test, and the execution result is encapsulated and returned to the control terminal.

2. The method according to claim 1, characterized in that, Before detecting the existence of an isolated target test environment on the device side, the following is also included: If the target test environment is not detected on the device, an isolated test instance to be set is created on the device through a reflection mechanism; the test instance to be set is independent of the preset instance of the preset test framework on the device. Through the reflection mechanism, the hidden class for interface automation services in the operating system is accessed and instantiated to obtain an object instance of the hidden class. Based on the object instance, establish a connection between the test instance to be set and the interface automation service to obtain a custom test instance; The context information of the application on the device is injected into the custom test instance through the reflection mechanism to obtain a custom test environment; the custom test environment includes resource access permissions and function execution permissions on the device. The connection method of the target interface is invoked to activate the custom test environment and obtain the target test environment; the target interface is used to interact with the interface automation service.

3. The method according to claim 1, characterized in that, Before determining the target atomic method corresponding to the atomic operation instruction to be tested based on a predefined set of mapping relationships, the method further includes: The native methods of the predefined atomic operation types are pre-compiled to obtain the predefined atomic operation methods. Establish a mapping relationship between the predefined atomic operation types and the predefined atomic operation methods to obtain the predefined mapping relationship set.

4. The method according to claim 1, characterized in that, The step of obtaining the type of atomic operation to be tested carried by the atomic operation instruction to be tested includes: The atomic operation instruction to be tested is parsed to obtain the operation field in the atomic operation instruction to be tested. Based on the operation field, the type of atomic operation to be tested of the atomic operation instruction to be tested is obtained.

5. The method according to claim 1, characterized in that, The step of executing the target atomic method in the target test environment to obtain the execution result of the atomic operation instruction under test includes: The parameters to be executed, corresponding to the parameter fields carried in the atomic operation instruction to be tested, are input into the target atomic method to obtain the atomic method to be executed. The atomic method to be executed is executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested.

6. The method according to claim 5, characterized in that, The type of atomic operation to be tested includes a progress identification type; the target atomic method corresponding to the progress identification type is used to indicate the progress value in the device interface. The step of executing the atomic method to be executed in the target test environment to obtain the execution result of the atomic operation instruction to be tested also includes: Based on the target test environment, obtain the current screenshot of the device. The current screenshot is converted from the first color space to the second color space to obtain the converted image of the current screenshot; Based on the second color space range preset for the progress bar color, the converted image is processed to extract the pixel region of the progress bar to obtain the progress bar filling region in the converted image. The candidate progress value of the converted image is obtained based on the pixel ratio between the progress bar filled area and the overall progress bar area in the converted image. If the verification result for the candidate progress value is detected as passed, then the candidate progress value is set as the execution result.

7. An instruction execution device, characterized in that, The device includes: The instruction receiving module is used to receive the atomic operation instruction to be tested from the control terminal; the atomic operation instruction to be tested is generated based on test cases; The instruction parsing module is used to obtain the type of atomic operation to be tested carried by the atomic operation instruction to be tested when an isolated target test environment is detected on the device side; the target test environment is independent of the preset test framework of the operating system on the device side. The method determination module is used to determine the target atomic method corresponding to the atomic operation type to be tested based on a predefined mapping relationship set; the predefined mapping relationship set includes at least one mapping relationship between a predefined atomic operation type and a precompiled atomic method; The method invocation module is used to execute the target atomic method in the target test environment, obtain the execution result of the atomic operation instruction to be tested, and encapsulate the execution result and return it to the control terminal.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.