CN113806206A - Shell process-based compatibility testing method, device, equipment and medium - Google Patents

Shell process-based compatibility testing method, device, equipment and medium Download PDF

Info

Publication number
CN113806206A
CN113806206A CN202010540190.1A CN202010540190A CN113806206A CN 113806206 A CN113806206 A CN 113806206A CN 202010540190 A CN202010540190 A CN 202010540190A CN 113806206 A CN113806206 A CN 113806206A
Authority
CN
China
Prior art keywords
test
shell process
initialization
instruction
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010540190.1A
Other languages
Chinese (zh)
Inventor
李括
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN202010540190.1A priority Critical patent/CN113806206A/en
Publication of CN113806206A publication Critical patent/CN113806206A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a shell process-based compatibility testing method, a device, equipment and a medium, wherein the method comprises the following steps: after a shell process command is started, registering a test service; after the test service registration is completed, initializing an automatic test framework; and forming the initialized automatic test frame into a test platform, and carrying out compatibility test on the function to be tested supported by the automatic test frame based on the test platform. After the shell command is executed, the invention can realize the test before the update of the automatic frame by registering the test service and initializing the automatic test frame, thereby realizing the compatibility test before and after the update.

Description

Shell process-based compatibility testing method, device, equipment and medium
Technical Field
The invention relates to the technical field of testing, in particular to a shell process-based compatibility testing method, device, equipment and medium.
Background
With the development of scientific technology, the automation test is developing more and more quickly, such as the framework Uiautomator for UI (User Interface) automation test promoted by Google is updated from 1.0 to 2.0. With the updating of the automated testing framework, the Android R system released by Google no longer supports the testing of the automated testing framework uiautomatorr 1.0 before updating. However, there are a number of Uiautomator1.0 based tests that are difficult to update to Uiautomator2.0 in a short time. Therefore, how to implement the compatibility test based on the uiautomatorr 1.0 is an urgent technical problem to be solved.
Disclosure of Invention
The invention mainly aims to provide a shell process-based compatibility test method, device, equipment and medium, and aims to solve the technical problem of how to realize the Uiautomator 1.0-based compatibility test in the prior art.
In order to achieve the above object, the present invention provides a shell process-based compatibility testing method, which is applied to a testing platform, wherein the testing platform comprises a testing end, a front end and a back end of asynchronous communication, and the shell process-based compatibility testing method comprises the following steps:
after a shell process command is started, registering a test service;
after the test service registration is completed, initializing an automatic test framework;
and forming the initialized automatic test frame into a test platform, and carrying out compatibility test on the function to be tested supported by the automatic test frame based on the test platform.
Optionally, after the shell process command is started, the step of registering the test service includes:
after a shell process command is started, acquiring an automatic test object according to an automatic construction method;
and connecting the test service based on the preset connection method of the automatic test object so as to register the test service.
Optionally, after the test service registration is completed, the initializing the automated test framework includes:
after the test service registration is completed, equipment initialization is carried out on a legal equipment object corresponding to the automatic test framework;
and establishing an incidence relation between the legal equipment object and the automatic test object based on equipment initialization, and completing initialization of the automatic test framework.
Optionally, the step of initializing the legal device object corresponding to the automated testing framework includes:
obtaining uninitialized legal equipment objects in the automatic test framework, and obtaining target objects of preset parameter classes based on a reflection technology;
and acquiring an initialization method corresponding to the legal equipment object, and activating the initialization method based on the target object and the legal equipment object so as to initialize the legal equipment object based on the initialization method.
Optionally, the step of obtaining the target object of the preset parameter class based on the reflection technology includes:
determining a source code corresponding to the legal equipment object and the preset parameter class based on a reflection technology, and determining a construction method corresponding to the source code;
based on the construction method, acquiring the position of the class and the type of the class in the source code, and packaging the position of the class and the type of the class into a parameter set;
and determining the operation construction method of the class according to the parameter set, and transmitting the parameter value of the class into the operation construction method to obtain the target object.
Optionally, the step of activating the initialization method based on the target object and the legal device object includes:
receiving an instruction for setting the access attribute of the initialization method, and setting the access attribute as a preset attribute according to the instruction;
and after the access attribute is a preset attribute, transmitting the target object and the legal equipment object to a preset activation command so as to activate the initialization method.
Optionally, the step of receiving an instruction to set an access attribute of the initialization method is followed by:
judging whether the instruction is effective or not, and if the instruction is effective, executing the step of setting the access attribute as a preset attribute according to the instruction;
and if the instruction is invalid, outputting prompt information.
Optionally, the step of performing a compatibility test on the function to be tested supported by the automated test framework based on the test platform includes:
enabling a reflection technology in the test platform and registering an auxiliary function based on the reflection technology;
acquiring page information based on the auxiliary function, and acquiring the information to be tested of the function to be tested according to the page information;
and performing compatibility test on the function to be tested according to the legal equipment object associated with the automatic test object in the test platform and the information to be tested.
Optionally, the step of performing a compatibility test on the function to be tested according to the legal device object associated with the automated test object in the test platform and the information to be tested includes:
identifying the information to be detected based on a legal device object, and determining a page display position corresponding to the function to be detected;
triggering a test instruction based on the page display position, and acquiring page change information corresponding to the test instruction;
and determining a test result of the function to be tested according to the page change information, and completing the compatibility test of the function to be tested.
Optionally, the function to be tested includes multiple sub-functions to be tested, and the step of performing a compatibility test on the function to be tested supported by the automated testing framework based on the testing platform includes:
and receiving an adjusting instruction, and adjusting the arrangement sequence of the plurality of sub-functions to be tested according to the adjusting instruction so as to update the functions to be tested.
Further, to achieve the above object, the present invention further provides a device for compatibility testing based on a shell process, where the device for compatibility testing based on a shell process includes:
the registration module is used for registering the test service after the shell process command is started;
the initialization module is used for initializing the automatic test framework after the test service registration is completed;
and the test module is used for forming the initialized automatic test frame into a test platform and carrying out compatibility test on the function to be tested supported by the automatic test frame based on the test platform.
Optionally, the registration module further includes:
the first acquisition unit is used for acquiring an automatic test object according to an automatic construction method after a shell process command is started;
and the connecting unit is used for connecting the test service based on the preset connecting method of the automatic test object so as to register the test service.
Optionally, the initialization module further includes:
the initialization unit is used for initializing the legal equipment object corresponding to the automatic test framework after the test service registration is completed;
and the establishing unit is used for establishing the incidence relation between the legal equipment object and the automatic test object based on equipment initialization so as to finish the initialization of the automatic test framework.
Optionally, the initialization unit is further configured to:
obtaining uninitialized legal equipment objects in the automatic test framework, and obtaining target objects of preset parameter classes based on a reflection technology;
and acquiring an initialization method corresponding to the legal equipment object, and activating the initialization method based on the target object and the legal equipment object so as to initialize the legal equipment object based on the initialization method.
Optionally, the initialization unit is further configured to:
determining a source code corresponding to the legal equipment object and the preset parameter class based on a reflection technology, and determining a construction method corresponding to the source code;
based on the construction method, acquiring the position of the class and the type of the class in the source code, and packaging the position of the class and the type of the class into a parameter set;
and determining the operation construction method of the class according to the parameter set, and transmitting the parameter value of the class into the operation construction method to obtain the target object.
Optionally, the initialization unit is further configured to:
receiving an instruction for setting the access attribute of the initialization method, and setting the access attribute as a preset attribute according to the instruction;
and after the access attribute is a preset attribute, transmitting the target object and the legal equipment object to a preset activation command so as to activate the initialization method.
Optionally, the initialization unit is further configured to:
judging whether the instruction is effective or not, and if the instruction is effective, executing the step of setting the access attribute as a preset attribute according to the instruction;
and if the instruction is invalid, outputting prompt information.
Optionally, the test module further comprises:
a registration unit for enabling a reflection technology in the test platform and registering an auxiliary function based on the reflection technology;
the second acquisition unit is used for acquiring page information based on the auxiliary function and acquiring the information to be tested of the function to be tested according to the page information;
and the test unit is used for carrying out compatibility test on the function to be tested according to the legal equipment object associated with the automatic test object in the test platform and the information to be tested.
Further, in order to achieve the above object, the present invention also provides a shell process-based compatibility testing apparatus, where the shell process-based compatibility testing apparatus includes a memory, a processor, and a shell process-based compatibility testing program stored in the memory and executable on the processor, and when the shell process-based compatibility testing program is executed by the processor, the steps of the shell process-based compatibility testing method are implemented.
Further, in order to achieve the above object, the present invention further provides a medium, where a shell process-based compatibility testing program is stored on the medium, and when the shell process-based compatibility testing program is executed by a processor, the steps of the shell process-based compatibility testing method are implemented.
The compatibility test method, the device, the equipment and the medium based on the shell process realize the compatibility test based on the Uiautomatorr 1.0 by executing the shell process command. After a shell process command is started, registering a test service, and initializing an automatic test frame after the test service registration is completed; and forming a compatible test platform by the initialized automatic test framework, and carrying out compatible test on the function to be tested supported by the automatic test framework according to the test platform. The function to be tested supported by the automatic test framework is the test generated based on Uiautomator1.0, after the shell command is executed, the test before the updating of the automatic test framework can be realized by registering the test service and initializing the automatic test framework, the problem that the test before the updating is not supported because the automatic test framework is updated is avoided, and the compatibility test before and after the updating is realized.
Drawings
Fig. 1 is a schematic structural diagram of a device hardware operating environment according to an embodiment of the shell process-based compatibility testing device of the present invention;
fig. 2 is a schematic flow chart of a first embodiment of the shell process-based compatibility testing method according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides a compatible testing device based on a shell process, and referring to fig. 1, fig. 1 is a schematic structural diagram of a device hardware operating environment related to an embodiment of the compatible testing device based on the shell process.
As shown in fig. 1, the shell process-based compatibility testing apparatus may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a memory device separate from the processor 1001 described above.
Those skilled in the art will appreciate that the hardware configuration of the shell process-based compatibility testing apparatus shown in fig. 1 does not constitute a limitation of the shell process-based compatibility testing apparatus, and may include more or fewer components than those shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, the memory 1005, which is a medium, may include an operating system, a network communication module, a user interface module, and a shell process-based compatibility test program. The operating system is a program for managing and controlling the compatible test equipment and the software resources based on the shell process, and supports the running of a network communication module, a user interface module, the compatible test program based on the shell process and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.
In the hardware structure of the shell process-based compatibility test equipment shown in fig. 1, the network interface 1004 is mainly used for connecting a background server and performing data communication with the background server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; the processor 1001 may call a shell process-based compatibility test program stored in the memory 1005 and perform the following operations:
after a shell process command is started, registering a test service;
after the test service registration is completed, initializing an automatic test framework;
and forming the initialized automatic test frame into a test platform, and carrying out compatibility test on the function to be tested supported by the automatic test frame based on the test platform.
Further, after the shell process command is started, the step of registering the test service includes:
after a shell process command is started, acquiring an automatic test object according to an automatic construction method;
and connecting the test service based on the preset connection method of the automatic test object so as to register the test service.
Further, the step of initializing the automated test framework after the test service registration is completed includes:
after the test service registration is completed, equipment initialization is carried out on a legal equipment object corresponding to the automatic test framework;
and establishing an incidence relation between the legal equipment object and the automatic test object based on equipment initialization, and completing initialization of the automatic test framework.
Further, the step of initializing the legal device object corresponding to the automated testing framework includes:
obtaining uninitialized legal equipment objects in the automatic test framework, and obtaining target objects of preset parameter classes based on a reflection technology;
and acquiring an initialization method corresponding to the legal equipment object, and activating the initialization method based on the target object and the legal equipment object so as to initialize the legal equipment object based on the initialization method.
Further, the step of obtaining the target object of the preset parameter class based on the reflection technology includes:
determining a source code corresponding to the legal equipment object and the preset parameter class based on a reflection technology, and determining a construction method corresponding to the source code;
based on the construction method, acquiring the position of the class and the type of the class in the source code, and packaging the position of the class and the type of the class into a parameter set;
and determining the operation construction method of the class according to the parameter set, and transmitting the parameter value of the class into the operation construction method to obtain the target object.
Further, the step of activating the initialization method based on the target object and the legal device object includes:
receiving an instruction for setting the access attribute of the initialization method, and setting the access attribute as a preset attribute according to the instruction;
and after the access attribute is a preset attribute, transmitting the target object and the legal equipment object to a preset activation command so as to activate the initialization method.
Further, after the step of receiving the instruction for setting the access attribute of the initialization method, the processor 1001 may call the shell process-based compatibility test program stored in the memory 1005, and perform the following operations:
judging whether the instruction is effective or not, and if the instruction is effective, executing the step of setting the access attribute as a preset attribute according to the instruction;
and if the instruction is invalid, outputting prompt information.
Further, the step of performing a compatibility test on the function to be tested supported by the automated test framework based on the test platform includes:
enabling a reflection technology in the test platform and registering an auxiliary function based on the reflection technology;
acquiring page information based on the auxiliary function, and acquiring the information to be tested of the function to be tested according to the page information;
and performing compatibility test on the function to be tested according to the legal equipment object associated with the automatic test object in the test platform and the information to be tested.
Further, the step of performing a compatibility test on the function to be tested according to the legal device object associated with the automated test object in the test platform and the information to be tested includes:
identifying the information to be detected based on a legal device object, and determining a page display position corresponding to the function to be detected;
triggering a test instruction based on the page display position, and acquiring page change information corresponding to the test instruction;
and determining a test result of the function to be tested according to the page change information, and completing the compatibility test of the function to be tested.
Further, the function to be tested includes a plurality of sub-functions to be tested, and before the step of performing compatibility test on the function to be tested supported by the automated test framework based on the test platform, the processor 1001 may call a shell process-based compatibility test program stored in the memory 1005, and perform the following operations:
and receiving an adjusting instruction, and adjusting the arrangement sequence of the plurality of sub-functions to be tested according to the adjusting instruction so as to update the functions to be tested.
The specific implementation of the shell process-based compatibility testing device of the present invention is substantially the same as the following embodiments of the shell process-based compatibility testing method, and is not described herein again.
The invention also provides a shell process-based compatibility testing method.
Referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of a shell process-based compatibility testing method according to the present invention.
While a logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order than that shown. Specifically, the method for the compatibility test based on the shell process in the embodiment includes:
step S10, after the shell process command is started, the test service is registered;
the shell process-based compatibility testing method in this embodiment is applied to a test server, and is suitable for implementing a compatible UI test (User interface test) before an automated frame is updated by registering a test service and initializing the automated test frame after the test server executes a shell process command. Where shell is a parser for a command line interface, which is itself a process that can parse a command line, such as parsing the syntax of a command, replacing variables with values in a command, parsing a pipe symbol and creating a pipe, etc. The shell process executes the command after each command line is analyzed, fork is performed on one sub-shell process, then exec calls a command program, the sub-shell process is replaced after the program is loaded, and the sub-shell process disappears due to process replacement of the command. After the called program is operated through the shell, the process and the kernel are interacted, and after the process is executed, the quitting state code of the process is received, so that the child process is prevented from becoming a permanent zombie process. The shell process command of this embodiment may be "app _ process/system/bin launcher", and after the shell process command is started to be executed, an automated construction method is called by reflection to register a test service. Specifically, after the shell process command is started, the step of registering the test service includes:
step S11, after the shell process command is started, acquiring an automatic test object according to an automatic construction method;
and step S12, connecting the test service based on the preset connection method of the automatic test object to register the test service.
Further, after detecting the start of the shell process command, initializing a HandlerThread and UiAutomationconnection object. HandlerThread is a lightweight asynchronous class, is used for realizing multithreading, avoids starting threads for many times, and is mainly used for realizing communication from a main thread to a sub thread. The UiAutomationconnection object is a remote object that passes from the shell to the Instrumentation for controlling certain privileged operations so that the shell has operating rights but the Instrumentation does not. The privileged operation needs to realize UiAutomation, and cross-application testing is realized by simulating user actions and executing screen detection. Where the shell is actually a process running am. jar, when a test is run by the shell command, a shell process is started to call run instrument to trigger the test process.
Further, after the initialization of the HandlerThread and UiAutomationconnection object is completed, the automated construction method is called through the reflection technology to acquire the automated test object through the automated construction method. Members of each type (including classes, structures, delegates, interfaces, enumerations, and the like) in the NET can be obtained at runtime through the Reflection technology, and the members include methods, attributes, events, constructors, and the like; the name, qualifier, and parameters, etc. of each member may also be obtained. When the type of the object is not known at the time of compiling, if the information of the constructor is obtained, the object can be directly created by the constructor. The present embodiment obtains a constructor by a reflection technique and forms the constructor into a construction method. The construction method is similar to the method with the same name and no return value type, is used for creating the object and completes the initialization of the object. The construction method formed in this embodiment is an automated construction method, that is, a UiAutomation construction method, and a handlethread and UiAutomation connection object are introduced according to the construction method, so that an automated test object can be obtained. And, the automated test object is represented by a UiAutomation object.
Further, the test service is connected according to a preset connection method of the automated test object, wherein the preset connection method is preferably a connect method of the UiAutomation object. The test service is connected through the preset connection method, the test service initialization of the shell process is completed, and the test service registration is realized. And connecting the test service, and after the initialization is completed, realizing UI test operation through an automatic test object obtained by the automatic construction method, namely the UiAutomation object.
The process of registering the test service can be realized by the following codes:
Figure BDA0002537845740000101
Figure BDA0002537845740000111
step S20, after the test service registration is completed, initializing the automated test framework;
further, after the test service registration is completed, the automated test framework uiautomation 1.0 is initialized. Because the UiAutomator1.0 test framework realizes the automatic test through UIdevice, the normal calling of the UiAutomator1.0 interface can be realized by initializing a legal UIdevice object in the Shell process, so that the initialization of the automatic test framework is realized. During testing, the UiDevice can simulate control over the equipment through the UiDevice object, such as lighting a screen, locking the screen, rotating the direction, capturing a picture and the like, or triggering a home key, a back key, a menu key and the like. However, the UIDevice initialization method and the parameter construction method required by the initialization are hidden, so the UIDevice is initialized by the reflection technology, the initialization of the automatic test frame is realized by the initialization of the UIDevice, and the normal call of the UIAutomator1.0 interface is realized. And the UiAutomator1.0 interface is called to realize a test flow and perform compatibility test.
Step S30, the initialized automated testing framework is formed into a testing platform, and the compatibility test is carried out on the function to be tested supported by the automated testing framework based on the testing platform.
Further, after the initialization of the automatic test frame is completed, the automatic test frame is formed into a test platform, and then the test platform performs a compatibility test on the function to be tested supported by the automatic test frame. The function to be tested supported by the automatic test framework is a test generated based on Uiautomator1.0, and the test is carried out through the test platform, so that the compatibility test before and after the automatic test framework is updated is realized.
Understandably, the test involves a lot of contents, and each content may or may not have a logical relationship, for example, there is no logical relationship between the login operation and the web page browsing operation, but there is a logical relationship between the login operation and the login information modification. For the content test with logical relationship, the sequence before and after the test can not be changed, that is, only after the login operation test is successful, the test for modifying the login information can be performed. But for the content test without logical relationship, the sequence of the test can be adjusted according to the requirement; for example, the login operation is tested first and then the webpage browsing operation is tested, or the webpage browsing operation is tested first and then the login operation is tested. And before the compatibility test is carried out on the functions to be tested according to the test platform, whether the adjustment requirements of each sub-function to be tested in the functions to be tested are met is judged. Specifically, the step of performing a compatibility test on the function to be tested supported by the automated test framework based on the test platform includes:
and step S31, receiving an adjusting instruction, and adjusting the arrangement sequence of the sub-functions to be tested according to the adjusting instruction so as to update the functions to be tested.
Further, a preset interval time is set, and whether an adjustment instruction is received within the preset time is judged. If the adjustment instruction is received, and the fact that the adjustment requirements are met on the sequence of the sub-functions to be tested before and after the test is represented, the sequence of the sub-functions to be tested is adjusted according to the adjustment instruction, the functions to be tested are updated through adjustment, and then the updated sub-functions to be tested are tested. And testing the sub-functions to be tested arranged in front, testing the sub-functions to be tested arranged behind, and embodying the testing sequence by using the arrangement sequence. If the adjusting instruction is not received, the testing sequence of each sub-function to be tested is not required to be adjusted by default, and the testing is carried out according to the original arrangement sequence of each sub-function to be tested. In addition, the adjustment instruction can also be triggered by outputting prompt information, and the prompt information is output in a dialog box mode and at least comprises two options of needing adjustment and not needing adjustment. If the option needing to be adjusted is selected, an adjusting instruction is triggered, the arrangement sequence of the sub-functions to be tested is adjusted according to the adjusting instruction, and the test is carried out after the functions to be tested are updated. Otherwise, if the option which does not need to be adjusted is selected, the adjusting instruction is not triggered, and the original arrangement sequence of the sub-functions to be tested is used for testing.
The compatibility test method based on the shell process realizes the compatibility test based on Uiautomator1.0 by executing the shell process command. After a shell process command is started, registering a test service, and initializing an automatic test frame after the test service registration is completed; and forming a compatible test platform by the initialized automatic test framework, and carrying out compatible test on the function to be tested supported by the automatic test framework according to the test platform. The function to be tested supported by the automatic test framework is the test generated based on Uiautomator1.0, after the shell command is executed, the test before the updating of the automatic test framework can be realized by registering the test service and initializing the automatic test framework, the problem that the test before the updating is not supported because the automatic test framework is updated is avoided, and the compatibility test before and after the updating is realized.
Further, based on the first embodiment of the shell process-based compatibility testing method of the present invention, a second embodiment of the shell process-based compatibility testing method of the present invention is provided.
The second embodiment of the shell process-based compatibility testing method is different from the first embodiment of the shell process-based compatibility testing method in that the step of initializing the automated testing framework after the test service registration is completed comprises the following steps:
step S21, after the test service registration is completed, equipment initialization is carried out on the legal equipment object corresponding to the automatic test framework;
the implementation implements initialization of the automation framework through reflection technology. Specifically, due to the initialization of the automatic test framework, the uiautomation 1.0 interface can be normally called to realize the initialization through initializing a legal UIDevice object in the Shell process. Therefore, the legal UIDevice object is used as a legal device object corresponding to the automatic test framework, and after the test service registration is completed, the initialization of the automatic test framework is realized by initializing the device of the legal device object. Specifically, the step of initializing the legal device object corresponding to the automated testing framework includes:
step S211, obtaining uninitialized legal equipment objects in the automatic test framework, and obtaining target objects of preset parameter classes based on a reflection technology;
further, through a static method getInstance () of the UiDevice, a legal device object which is not initialized in the automatic test framework, namely a legal UIDevice object, is obtained. And then acquiring a construction method through a reflection technology, determining parameters of initialization requirements by the construction method, and determining target objects of preset parameter classes by the parameters for initialization. Specifically, the step of obtaining the target object of the preset parameter class based on the reflection technology includes:
a1, determining the source code corresponding to the legal equipment object and the preset parameter class based on reflection technology, and determining the construction method corresponding to the source code;
a2, based on the construction method, obtaining the position of the class and the type of the class in the source code, and packaging the position of the class and the type of the class as a parameter set;
step a3, determining the operation construction method of the class according to the parameter set, and transmitting the parameter value of the class into the operation construction method to obtain the target object.
Furthermore, the ShellUi Automatorbridge parameter is used as a preset parameter class, and the object of the ShellUi Automatorbridge parameter is acquired as a target object through a reflection technology. Specifically, a source code of a legal device object on a preset parameter type is determined through a reflection basis, and a construction method of the source code is searched. And acquiring the position of the class and the type of the class in the source code by the searched construction method, and encapsulating the acquired position of the class and the type of the class to obtain a parameter set. And determining a construction method of the source code during operation according to the parameter set, setting the construction method of the source code during operation as a class operation construction method, and transmitting the parameter value of the class into the operation construction method to obtain the target object.
The above-mentioned acquisition of the target object can be realized by the following codes:
Class[]parameterTypes=new Class[1];
Object[]parameterValues=new Object[1];
parameter set of construction method
parameterTypes[0]=UiAutomation.class;
Parameter values of construction method
parameterValues[0]=mUiAutomation;
// obtaining class objects by class name
Class clazz=
Class.forName("com.android.uiautomator.core.ShellUiAutomatorBridge");
Acquiring construction method through reflection and calling construction method to acquire object instance (namely target object)
final Object object=
clazz.getConstructor(parameterTypes).newInstance(parameterValues);
Step S212, obtaining an initialization method corresponding to the legal device object, and activating the initialization method based on the target object and the legal device object, so as to perform device initialization on the legal device object based on the initialization method.
Further, the initialization method of UiDevice is obtained as the initialization method corresponding to the legitimate device object. In the acquisition process, the method parameter list is acquired first, and then the method parameter value is acquired, wherein the parameter value is substantially the target object. And then the initialization method is obtained through the parameter list of the method. And then, the initialization method is activated by combining the target object and the legal equipment object, and equipment initialization is carried out on the legal equipment object by the activated initialization method. The method is characterized in that the initialization method is activated through the target object and the legal equipment object, and the process is essentially a process of transmitting the target object and the legal equipment object into a preset activation command and parameterizing the initialization method. And, the preset activation command is preferably a preset invoke command. Specifically, the step of activating the initialization method based on the target object and the legal device object includes:
step b1, receiving an instruction for setting the access attribute of the initialization method, and setting the access attribute as a preset attribute according to the instruction;
step b2, after the access attribute is the preset attribute, transmitting the target object and the legal device object to a preset activation command to activate the initialization method.
Further, before parameterizing the initialization method, the access attribute of the initialization method is set. Specifically, an instruction for setting the access attribute of the initialization method is received, and the access attribute is set as a preset attribute according to the instruction, wherein the preset attribute is a true attribute. That is, the instruction is an instruction carrying a true attribute, and the access attribute is set to true by the instruction. After the access attribute is set as the preset attribute, the target object and the legal equipment object are transmitted to a preset activation command, and the initialization method is activated through the preset activation command, namely, the parameterization of the initialization method is realized.
Understandably, the preset attribute set for the access attribute in the compatibility test process is a specific true attribute, and other attributes cannot realize the compatibility test. Specifically, the step of receiving an instruction to set an access attribute of the initialization method includes:
step c1, judging whether the instruction is valid, if the instruction is valid, executing the step of setting the access attribute as the preset attribute according to the instruction;
and c2, if the instruction is invalid, outputting a prompt message.
Further, judging the validity of the instruction by detecting whether the preset attribute carried in the instruction is true or not; if the carried preset attribute is true attribute, judging that the instruction is valid, and setting the access attribute as the preset attribute, namely true attribute according to the instruction. If the carried preset attribute is not the true attribute, the instruction is judged to be invalid, prompt information is output to remind of carrying out validity setting on the access attribute, the access attribute is set to be the preset attribute, and parameterization is carried out on the initialization method on the basis of the preset attribute.
The process of initializing the legal device object can be implemented by the following codes:
// list of acquisition method parameters
parameterTypes[0]=
Class.forName("com.android.uiautomator.core.UiAutomatorBridge");
// obtaining method parameter values
parameterValues[0]=object;
Method for initializing parameter acquisition
Method initMetho=
uiDevice.getClass().getMethod("initialize",parameterTypes);
// set Access Attribute to true
initMetho.setAccessible(true);
Method parameter values and uiDevice object invocation methods
initMetho.invoke(uiDevice,parameterValues);
Step S22, establishing the association relationship between the legal device object and the automatic test object based on the device initialization, and completing the initialization of the automatic test framework.
Further, after the legal device object is initialized, i.e. the legal UIdevice object is initialized, an association relationship is established between the legal device object and the automatic test object, i.e. the association relationship between the legal UIdevice object and the UIAutomation object is established. Therefore, after the automatic test object is connected with the test service, the legal equipment object in the automatic test frame is connected with the test service through the incidence relation between the legal equipment object initialized by the equipment in the automatic test frame and the automatic test object, so that the test is conveniently carried out through the legal equipment object, and the initialization of the automatic test frame is completed. In the test process, an automatic test object associated with a legal device object calls a UiAutomator1.0 interface to realize compatible test.
The implementation realizes the initialization of the automatic frame through the reflection technology so as to form a test platform after the initialization is completed and carry out compatibility test on the function to be tested supported before the automatic test frame is updated. During testing, an Android system app _ process command is used for starting an apk file, and a launcher type running program for realizing a main method is specified. Jar information is added to CLASSPATH in the command to load the uiautomat test dependency. When the command is executed, the static main method of the launcher class is started to execute, the Shell process registration test service is firstly carried out in the main method, then the Shell process initialization automatic test framework operation is carried out, and then the business test case is called, so that the compatibility test can be realized.
Further, based on the first or second embodiment of the shell process-based compatibility testing method of the present invention, a third embodiment of the shell process-based compatibility testing method of the present invention is proposed.
The third embodiment of the shell process-based compatibility testing method is different from the first or second embodiment of the shell process-based compatibility testing method in that the step of performing compatibility testing on the function to be tested supported by the automated testing framework based on the testing platform comprises the following steps:
step S31, enabling a reflection technology in the test platform, and registering an auxiliary function based on the reflection technology;
step S32, acquiring page information based on the auxiliary function, and acquiring the information to be tested of the function to be tested according to the page information;
and step S33, performing compatibility test on the function to be tested according to the legal equipment object associated with the automatic test object in the test platform and the information to be tested.
According to the implementation, after the automatic test frame is formed into the test platform, the compatibility test is carried out through the test platform. Specifically, a reflection technique is started by a test platform formed by an automated test framework, and an accessibility service (accessibility service) is registered by the reflection technique. The auxiliary function is a Service provided by an Android system, the Service is inherited by the auxiliary function, and the Service provides an enhanced user interface. The provided functions comprise searching for interface elements and realizing simulated clicking, and the permission nodes are searched and clicked through the provided searching nodes and the interfaces related to the simulated clicking, so that automatic testing is realized.
Further, the page information is obtained through a search interface element function in the registered auxiliary functions, and the obtained page information at least comprises page structure information and attribute information of page view assembly. And for the page structure, each specific view component is combined and displayed in a hierarchical mode and belongs to xml structured information. For the view component, specific attribute information such as text information (text) of page display, resource-id (resource-id) specified by a program, application package name (package), component class name (class), description information (content-desc), screen coordinate information (centers), operation attribute, and the like is contained. And searching the coordinate position of the function to be tested, the contained text information and the like through the page information, and acquiring the searched information serving as the information to be tested of the function to be tested. And then testing the function to be tested according to the legal equipment object and the information to be tested which are associated with the automatic test object in the test platform. Specifically, the step of performing compatibility test on the function to be tested according to the legal device object and the information to be tested associated with the automatic test object in the test platform comprises the following steps:
step S331, identifying the information to be tested based on a legal device object, and determining a page display position corresponding to the function to be tested;
step S332, triggering a test instruction based on the page display position, and acquiring page change information corresponding to the test instruction;
step S333, determining the test result of the function to be tested according to the page change information, and completing the compatibility test of the function to be tested.
Furthermore, the information to be detected is identified through the legal equipment object, the coordinate position contained in the information to be detected is identified, and the page display position of the function to be detected in the display interface is determined according to the coordinate position. And further triggering a test instruction by simulating clicking on the page display position, and simultaneously acquiring the response of the display interface to the test instruction to obtain page change information corresponding to the test instruction. In addition, expected response information is set in advance for the function to be tested, and page change information and the expected response information are compared. If the similarity between the actual response and the expected response is larger than the preset threshold, the difference between the actual response and the expected response is judged to be small, and the test of the function to be tested is successful. Otherwise, if the similarity between the page change information and the expected response information is smaller than the preset threshold, it is determined that the difference between the actual response and the expected response is large, and the test of the function to be tested fails. Therefore, the test result of the function to be tested is determined according to the page change information, and the compatibility test of the function to be tested is completed.
After the test platform is formed, the automatic compatibility test is realized through the auxiliary function registered by the reflection technology, the test of the automatic test frame before updating is supported, and the compatible use of the automatic test frame before and after updating is facilitated.
The invention also provides a compatibility testing device based on the shell process. The compatible testing device based on the shell process comprises:
the registration module is used for registering the test service after the shell process command is started;
the initialization module is used for initializing the automatic test framework after the test service registration is completed;
and the test module is used for forming the initialized automatic test frame into a test platform and carrying out compatibility test on the function to be tested supported by the automatic test frame based on the test platform.
Further, the registration module further comprises:
the first acquisition unit is used for acquiring an automatic test object according to an automatic construction method after a shell process command is started;
and the connecting unit is used for connecting the test service based on the preset connecting method of the automatic test object so as to register the test service.
Further, the initialization module further includes:
the initialization unit is used for initializing the legal equipment object corresponding to the automatic test framework after the test service registration is completed;
and the establishing unit is used for establishing the incidence relation between the legal equipment object and the automatic test object based on equipment initialization so as to finish the initialization of the automatic test framework.
Further, the initialization unit is further configured to:
obtaining uninitialized legal equipment objects in the automatic test framework, and obtaining target objects of preset parameter classes based on a reflection technology;
and acquiring an initialization method corresponding to the legal equipment object, and activating the initialization method based on the target object and the legal equipment object so as to initialize the legal equipment object based on the initialization method.
Further, the initialization unit is further configured to:
determining a source code corresponding to the legal equipment object and the preset parameter class based on a reflection technology, and determining a construction method corresponding to the source code;
based on the construction method, acquiring the position of the class and the type of the class in the source code, and packaging the position of the class and the type of the class into a parameter set;
and determining the operation construction method of the class according to the parameter set, and transmitting the parameter value of the class into the operation construction method to obtain the target object.
Further, the initialization unit is further configured to:
receiving an instruction for setting the access attribute of the initialization method, and setting the access attribute as a preset attribute according to the instruction;
and after the access attribute is a preset attribute, transmitting the target object and the legal equipment object to a preset activation command so as to activate the initialization method.
Further, the initialization unit is further configured to:
judging whether the instruction is effective or not, and if the instruction is effective, executing the step of setting the access attribute as a preset attribute according to the instruction;
and if the instruction is invalid, outputting prompt information.
Further, the test module further comprises:
a registration unit for enabling a reflection technology in the test platform and registering an auxiliary function based on the reflection technology;
the second acquisition unit is used for acquiring page information based on the auxiliary function and acquiring the information to be tested of the function to be tested according to the page information;
and the test unit is used for carrying out compatibility test on the function to be tested according to the legal equipment object associated with the automatic test object in the test platform and the information to be tested.
Further, the test unit is further configured to:
identifying the information to be detected based on a legal device object, and determining a page display position corresponding to the function to be detected;
triggering a test instruction based on the page display position, and acquiring page change information corresponding to the test instruction;
and determining a test result of the function to be tested according to the page change information, and completing the compatibility test of the function to be tested.
Further, the function to be tested includes a plurality of sub-functions to be tested, and the shell process-based compatibility testing apparatus further includes:
and the receiving module is used for receiving an adjusting instruction and adjusting the arrangement sequence of the plurality of sub-functions to be tested according to the adjusting instruction so as to update the functions to be tested.
The specific implementation of the compatible testing device based on the shell process is basically the same as that of the embodiments of the compatible testing method based on the shell process, and the detailed description is omitted here.
In addition, the embodiment of the invention also provides a medium.
The medium is stored with a shell process-based compatibility testing program, and the steps of the shell process-based compatibility testing method are realized when the shell process-based compatibility testing program is executed by a processor.
The media of the present invention may be computer-readable storage media, and the specific implementation manner of the media of the present invention is substantially the same as that of each embodiment of the above-described shell process-based compatibility testing method, and details are not described here.
The present invention is described in connection with the accompanying drawings, but the present invention is not limited to the above embodiments, which are only illustrative and not restrictive, and those skilled in the art can make various changes without departing from the spirit and scope of the invention as defined by the appended claims, and all changes that come within the meaning and range of equivalency of the specification and drawings that are obvious from the description and the attached claims are intended to be embraced therein.

Claims (10)

1. A compatible testing method based on a shell process is characterized by comprising the following steps:
after a shell process command is started, registering a test service;
after the test service registration is completed, initializing an automatic test framework;
and forming the initialized automatic test frame into a test platform, and carrying out compatibility test on the function to be tested supported by the automatic test frame based on the test platform.
2. The shell process-based compatibility testing method of claim 1, wherein the step of registering a test service after the shell process command is initiated comprises:
after a shell process command is started, acquiring an automatic test object according to an automatic construction method;
and connecting the test service based on the preset connection method of the automatic test object so as to register the test service.
3. The shell process-based compatibility testing method of claim 2, wherein initializing the automated testing framework after completion of the test service registration comprises:
after the test service registration is completed, equipment initialization is carried out on a legal equipment object corresponding to the automatic test framework;
and establishing an incidence relation between the legal equipment object and the automatic test object based on equipment initialization, and completing initialization of the automatic test framework.
4. The shell process-based compatibility testing method of claim 3, wherein said step of initializing a legal device object corresponding to said automated testing framework comprises:
obtaining uninitialized legal equipment objects in the automatic test framework, and obtaining target objects of preset parameter classes based on a reflection technology;
and acquiring an initialization method corresponding to the legal equipment object, and activating the initialization method based on the target object and the legal equipment object so as to initialize the legal equipment object based on the initialization method.
5. The shell process-based compatibility testing method according to claim 4, wherein said step of obtaining the target object of the preset parameter class based on the reflection technique comprises:
determining a source code corresponding to the legal equipment object and the preset parameter class based on a reflection technology, and determining a construction method corresponding to the source code;
based on the construction method, acquiring the position of the class and the type of the class in the source code, and packaging the position of the class and the type of the class into a parameter set;
and determining the operation construction method of the class according to the parameter set, and transmitting the parameter value of the class into the operation construction method to obtain the target object.
6. The shell process-based compatibility testing method of claim 4, wherein said step of activating said initialization method based on said target object and said legitimate device object comprises:
receiving an instruction for setting the access attribute of the initialization method, and setting the access attribute as a preset attribute according to the instruction;
and after the access attribute is a preset attribute, transmitting the target object and the legal equipment object to a preset activation command so as to activate the initialization method.
7. The shell process-based compatibility testing method of claim 6, wherein said step of receiving an instruction to set an access attribute of said initialization method is followed by:
judging whether the instruction is effective or not, and if the instruction is effective, executing the step of setting the access attribute as a preset attribute according to the instruction;
and if the instruction is invalid, outputting prompt information.
8. A shell process-based compatibility testing device is characterized in that the shell process-based compatibility testing device comprises:
the registration module is used for registering the test service after the shell process command is started;
the initialization module is used for initializing the automatic test framework after the test service registration is completed;
and the test module is used for forming the initialized automatic test frame into a test platform and carrying out compatibility test on the function to be tested supported by the automatic test frame based on the test platform.
9. A shell process-based compatibility testing device, comprising a testing end, a front end and a back end for asynchronous communication, and further comprising a memory, a processor, and a shell process-based compatibility testing program stored in the memory and executable on the processor, wherein the steps of the shell process-based compatibility testing method according to any one of claims 1 to 7 are implemented when the processor executes the shell process-based compatibility testing program.
10. A medium having stored thereon a shell process-based compatibility testing program, which when executed by a processor, performs the steps of the shell process-based compatibility testing method of any of claims 1-7.
CN202010540190.1A 2020-06-12 2020-06-12 Shell process-based compatibility testing method, device, equipment and medium Pending CN113806206A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010540190.1A CN113806206A (en) 2020-06-12 2020-06-12 Shell process-based compatibility testing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010540190.1A CN113806206A (en) 2020-06-12 2020-06-12 Shell process-based compatibility testing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN113806206A true CN113806206A (en) 2021-12-17

Family

ID=78892312

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010540190.1A Pending CN113806206A (en) 2020-06-12 2020-06-12 Shell process-based compatibility testing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN113806206A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484176A (en) * 2014-12-16 2015-04-01 北京奇虎科技有限公司 Android system window object acquiring method and android system window object acquiring device
CN106021101A (en) * 2016-05-16 2016-10-12 北京奇虎科技有限公司 Method and device for testing mobile terminal

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484176A (en) * 2014-12-16 2015-04-01 北京奇虎科技有限公司 Android system window object acquiring method and android system window object acquiring device
CN106021101A (en) * 2016-05-16 2016-10-12 北京奇虎科技有限公司 Method and device for testing mobile terminal

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
榴莲ALICE: ""Android自动化测试框架UIAutomator原理浅析"", pages 1, Retrieved from the Internet <URL:《https://www.cnblogs.com/aliceyang/p/11962718.html》> *
聆风牧雨: ""Uiautomator1.0与Uiautomator2.0测试项目搭建与运行原理"", pages 3 - 21, Retrieved from the Internet <URL:《https://www.cnblogs.com/walker-world/p/12521079.html》> *

Similar Documents

Publication Publication Date Title
US11960912B2 (en) Methods for user interface generation and application modification
US6668370B1 (en) Synchronous execution of object-oriented scripts and procedural code from within an interactive test facility
US8640104B2 (en) Computer method and apparatus for debugging in a dynamic computer language
US8850388B2 (en) Controlling application features
US8108834B2 (en) Defining and executing processes using declarative programming language constructs
US6484276B1 (en) Method and apparatus for providing extensible object-oriented fault injection
US8543994B2 (en) Developing java server components without restarting the application server
US7882492B2 (en) Intelligent computer program debugger, and system and method for implementing the same
US8615750B1 (en) Optimizing application compiling
US7533114B2 (en) Mobile device having extensible software for presenting server-side applications, software and methods
US20130305212A1 (en) Dry-run design time environment
US10209968B2 (en) Application compiling
US20090300578A1 (en) System and Method For Developing An Application For Extending Access to Local Software Of A Wireless Device
KR20140023971A (en) Registration and execution of highly concurrent processing tasks
US20170322817A1 (en) Object-oriented programming system and library
CN111880804A (en) Application program code processing method and device
US20160170739A1 (en) Alter application behaviour during runtime
CN113760397A (en) Interface call processing method, device, equipment and storage medium
CN113806206A (en) Shell process-based compatibility testing method, device, equipment and medium
CN100419711C (en) Emitter for service debug command, and processing method
US20050034120A1 (en) Systems and methods for cooperatively building public file packages
Rasche et al. Dynamic updates of graphical components in the. Net framework
Hunt Essential JavaBeans Fast
API et al. Monitoring and Management
Harris et al. Performance tuning, configuration, and debugging

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination