Disclosure of Invention
The invention aims to solve the defects of the prior art and provides a mobile game automatic testing method and system based on a Unity platform, which automatically execute the mobile game test for collecting custom type data, thereby obtaining the effects of saving the workload and the operation error of manual operation of testers and being independent of a mobile phone operating system.
In order to achieve the above object, the present invention adopts the following technical means.
Firstly, the invention provides a mobile phone game automatic testing method based on a Unity platform, which comprises the following steps: starting a mobile phone game to be tested, and downloading a test configuration file from a server; calling an NGUI button response function interface of the Unity platform, and executing the operation to be tested specified by the test configuration file; monitoring and recording performance data of the mobile phone game during the execution of the operation to be tested; after the test is finished, the performance data is exported to be an externally readable file and is transmitted to the server.
In the above method of the present invention, the NGUI button response function interface of the Unity platform is called through a reflection mechanism.
In the method of the invention, the NGUI button response function interface of the Unity platform is called by the sendMessage function of the Unity platform.
In the method of the invention, the performance data of the mobile phone game is monitored and recorded in a code injection mode during the operation to be tested.
In the method of the invention, the performance data of the mobile phone game is monitored and recorded by a built-in performance analyzer of the open Unity during the operation to be tested.
In the method of the present invention, the running time of each frame is obtained through the Update function of Unity during the execution of the operation to be tested.
In the above method of the present invention, the test configuration file at least includes game scene waypoints and user interface control information.
Further, in the method of the present invention, according to the game scene waypoint and the user interface control information included in the test configuration file, the calling order and interval time of each control on the user interface called by the test script and whether to collect function stack data are set.
In addition, the invention also provides a mobile phone game automatic testing system based on the Unity platform, which comprises the following modules: the configuration module is used for starting a mobile phone game to be tested and downloading a test configuration file from the server;
the execution module is used for calling an NGUI button response function interface of the Unity platform and executing the operation to be tested specified by the test configuration file;
the monitoring module is used for monitoring and recording the performance data of the mobile phone game during the execution of the operation to be tested;
and the recording module is used for exporting the performance data into an externally readable file after the test is finished and transmitting the externally readable file to the server.
In the above system of the present invention, the NGUI button response function interface of the Unity platform is called through a reflection mechanism.
In the system of the invention, the NGUI button response function interface of the Unity platform is called by the sendMessage function of the Unity platform.
In the system of the invention, the monitoring module monitors and records the performance data of the mobile phone game in a code injection mode during the execution of the operation to be tested.
In the system of the invention, the monitoring module monitors and records the performance data of the mobile phone game by starting a built-in performance analyzer of Unity during the operation to be tested.
In the system of the present invention, the monitoring module obtains the running time of each frame through the Update function of Unity during the execution of the operation to be tested.
In the system of the present invention, the test configuration file executed by the execution module at least includes game scene waypoints and user interface control information.
Further, in the system of the present invention, according to the game scene waypoint and the user interface control information included in the test configuration file, the execution module sets the call sequence and interval time of each control on the user interface called by the test script and whether to collect function stack data.
Finally, the present invention also provides a computer readable storage medium having computer instructions stored thereon. The instructions when executed by the processor implement the steps of a method as in any one of the preceding.
The invention has the beneficial effects that: the automatic testing method and the system for the mobile game, which can self-define data type collection, reduce the testing workload and the operation error of testers, thereby improving the testing efficiency; meanwhile, the method and the system can also run across platforms.
Detailed Description
The conception, the specific structure and the technical effects of the present invention will be clearly and completely described in conjunction with the embodiments and the accompanying drawings to fully understand the objects, the schemes and the effects of the present invention. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The same reference numbers will be used throughout the drawings to refer to the same or like parts.
Referring to a flow chart of a mobile phone game automatic testing method shown in fig. 1, in one embodiment of the method of the present invention, the present invention discloses a mobile phone game automatic testing method based on a Unity platform, which includes the following steps: starting a mobile phone game to be tested, and downloading a test configuration file from a server; calling an NGUI button response function interface of the Unity platform, and executing the operation to be tested specified by the test configuration file (for example, the configuration file is mounted on the game in an AddComponent mode through an administrator command provided by a debugging version of the mobile phone game); monitoring and recording performance data of the mobile phone game during the execution of the operation to be tested; after the test is finished, the performance data is exported to be an externally readable file and is transmitted to the server. In one embodiment of the invention, the collected performance data can be uploaded to a web page display directly at the same time. The uploading process can be set to automatic uploading without external manual control.
Specifically, in one method embodiment of the present invention, the various NGUI button response function interfaces used to implement the Call Unity platform may be created based on objects (Type types) encapsulating assemblies, modules and types provided by the C # in reflection mechanism. Wherein, the reflection can dynamically create UI control instances within the tape detection game and bind to or acquire types from existing objects through the types, thereby invoking methods thereof to perform specific user interface operations specified by the test configuration file. Further, when using an instance of a control within a cell phone game, the properties of the control itself may also be accessed through the C # reflection mechanism (e.g., whether the control is available at that time, etc. the current property state of the control).
As an alternative to the above-described reflection mechanism, in another method embodiment of the present invention, various NGUI button response function interfaces calling the Unity platform can be implemented through the sendMessage function of the Unity itself. Specifically, according to the identification code of the control specified by the test configuration file and the test operation of the control, the sendMessage function directly sends related information to execute the specific test operation.
In one embodiment of the method, the performance data of the mobile phone game is monitored and recorded in a code injection mode during the operation to be tested. Specifically, the code injected into the mobile game can specifically monitor the memory occupation of the mobile game, the memory occupation of the Mono virtual heap and the performance-related key function memory allocation in real time.
Further, in the above method embodiment of the present invention, by starting a profile performance analysis tool built in the Unity, and setting and acquiring more detailed performance parameters in the test configuration file, more detailed function stack monitoring is performed to determine a performance bottleneck problem in the actual running of, for example, a mobile phone game.
In one method embodiment of the invention, the running time of each frame is obtained by the Update function of Unity during the execution of the operation to be tested. Based on the running time of each Frame, the tester can determine the real-time Frame Per Second (FPS) in each running stage of the mobile phone game and detect the running fluency of each stage of the game. Meanwhile, the embodiment may further automatically save the information into the local file at regular intervals (for example, 30 seconds) by monitoring the information including, but not limited to, the memory usage of the mobile game, the memory usage of the Mono virtual heap, and the memory allocation of the performance-related key function in real time.
In one embodiment of the method of the present invention, for some mobile games related to a scene, the test configuration file at least includes game scene waypoints and user interface control information. Where the game scene waypoints are specific location coordinates in the game scene. The information is used to simulate actual user actions, such as a user operating his character to walk to one or more designated locations in a game scene. The user interface control information at least comprises the calling sequence and the interval time of each control on the user interface so as to record the user operation in detail.
Further, in an embodiment of the method of the present invention, according to the game scene waypoint and the user interface control information included in the test configuration file, the calling order and interval time of each control on the user interface called by the test script and whether to collect function stack data are set. When a specific control calling function is automatically executed according to the configuration file, the related function stack is monitored so as to collect specific function stack data. After the test operation is completed, the whole data is uniformly exported to be an externally readable file and is transmitted to a designated position of a server (such as a test server), so that the historical data can be conveniently compared.
Referring to a block diagram of the mobile game automation test system shown in fig. 2, in a system embodiment of the present invention, the present invention discloses a mobile game automation test system based on a Unity platform, which includes the following modules: the configuration module is used for starting a mobile phone game to be tested and downloading a test configuration file from the server; the execution module is used for calling an NGUI button response function interface of the Unity platform and executing the operation to be tested specified by the test configuration file (for example, the configuration file is mounted on the game in an AddComponent mode through an administrator command provided by a debugging version of a mobile phone game); the monitoring module is used for monitoring and recording the performance data of the mobile phone game during the execution of the operation to be tested; and the recording module is used for exporting the performance data into an externally readable file after the test is finished and transmitting the externally readable file to the server. . In one embodiment of the invention, the collected performance data can be uploaded to a web page display directly at the same time. The uploading process can be set to automatic uploading without external manual control.
Specifically, in one system embodiment of the present invention, the various NGUI button response function interfaces that the execution module uses to implement the Call Unity platform may be created based on objects (Type types) that encapsulate the set of programs, modules and types provided by the C # reflex mechanism. Wherein, the reflection can dynamically create UI control instances in the game with detection, and bind to the existing objects through types, or acquire the types from the existing objects, thereby invoking the system thereof to execute specific user interface operations specified by the test configuration file. Further, when using an instance of a control within a cell phone game, the properties of the control itself may also be accessed through the C # reflection mechanism (e.g., whether the control is available at that time, etc. the current property state of the control).
As an alternative to the above reflection mechanism, in another system embodiment of the present invention, the execution module may implement various NGUI button response function interfaces calling the Unity platform through the sendMessage function of the Unity itself. Specifically, according to the identification code of the control specified by the test configuration file and the test operation of the control, the sendMessage function directly sends related information to execute the specific test operation.
In one embodiment of the system of the invention, the monitoring module monitors and records the performance data of the mobile phone game in a code injection mode during the execution of the operation to be tested. Specifically, the monitoring module may specifically monitor, in real time, the code injected into the mobile game, including but not limited to memory usage of the mobile game, memory usage of the Mono virtual heap, and performance-related key function memory allocation.
Further, in the above system embodiment of the present invention, the monitoring module may execute more detailed function stack monitoring by opening a profile performance analysis tool built in Unity and setting and acquiring more detailed performance parameters in the test configuration file, so as to determine a performance bottleneck problem in actual operation of, for example, a mobile phone game.
In one system embodiment of the present invention, the monitoring module obtains the running time of each frame through the Update function of Unity during the execution of the operation to be tested. Based on the running time of each Frame, the tester can determine the real-time Frame Per Second (FPS) in each running stage of the mobile phone game and detect the running fluency of each stage of the game. Meanwhile, the embodiment may further automatically save the information into the local file at regular intervals (for example, 30 seconds) by monitoring the information including, but not limited to, the memory usage of the mobile game, the memory usage of the Mono virtual heap, and the memory allocation of the performance-related key function in real time.
In one embodiment of the system of the present invention, for some mobile games related to a scene, the test configuration file at least includes game scene waypoints and user interface control information. Where the game scene waypoints are specific location coordinates in the game scene. The information is used to simulate actual user actions, such as a user operating his character to walk to one or more designated locations in a game scene. The user interface control information at least comprises the calling sequence and the interval time of each control on the user interface so as to record the user operation in detail.
Further, in a system embodiment of the present invention, according to the game scene waypoint and the user interface control information included in the test configuration file, the calling order and interval time of each control on the user interface called by the test script and whether to collect function stack data are set. When a specific control calling function is automatically executed according to the configuration file, the related function stack is monitored so as to collect specific function stack data. After the test operation is completed, the whole data is uniformly exported to be an externally readable file and is transmitted to a designated position of a server (such as a test server), so that the historical data can be conveniently compared.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct combination or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated into two processing units, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in two computer readable storage media. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.