Excellent gifted test Share | game UI automated testing can be carried out so

Gifted test is a professional automated test platform provides automated testing, compatibility testing, cloud real machine - multi-dimensional remote real machine rental, vulnerability analysis and other testing services, providing high-performance testing services!


For the current two game engine cocos-2dx, unity3D, its UI test automation technology solutions have been realized. Can get, set each attribute UI objects, methods and interfaces may call some UI objects and engines, drive capability Based UI engine. With these capabilities after, technically already can be achieved based UI test automation engine game. But the mere ability to drive is not enough to implement UI UI test automation of a game.

UI test automation generally need to meet several conditions: UI is relatively stable, operational processes and results can be expected, long product life cycle.

UI is relatively stable:

Refers to the UI elements and layouts between versions were little changed, the key attributes of each UI element (in particular attribute used to uniquely identify the UI elements) remained stable, other properties may vary as needed. Because the test script is the direct operation of these UI elements, if UI is not stable enough, test scripts can not locate UI elements, can not effectively control the UI elements.

Operational processes and results can be expected:

It refers to the process of interaction and expected results are clear, such as sending a text message to QQ function, for example, their interaction and the expected results are relatively clear, even if there is a branch operation is limited and can be easily traversed. Such a test script design is relatively simple, basic linear actuator is down. If the interaction process and the expected results are not clear, there are too many random, will greatly increase the complexity of the logic of the script. Overly complex script logic for the requirements of high capacity testers, and will improve post-test script maintenance costs.

Long product life cycle:

Because the development of UI automated test scripts, maintenance costs are high, if the tested product life cycle is too short, or send only a few versions, will lead to automated testing of input-output ratio is too low.

UI test automation based on the requirements described above, we have to look at the situation of the game, most games often do not have the above conditions, often: UI unstable: UI cool, all kinds of special effects, each version will be updated UI.

Operation of the process and the results difficult to predict:

Course of the fighting game filled with all kinds of randomness and uncertainty player operation, leading to the expected results require complex real-time calculations can draw, we can not be expected in advance.

Short life cycle:

Many games only a few months of the life cycle. These factors have led to the game's UI Automation testing cost is too high.

Indeed a lot of games are not suitable for automated UI tests, but for some long cycle life, high-income investment in human games do UI test automation is still very valuable. And with the upgrading of staff skills test tools and test capabilities, some ordinary game can also undertake some UI test automation.

Here's how to carry out simple game UI test automation share some personal thoughts.

Do any UI test automation should consider input-output ratio, we press the input-output ratio from high to low to discuss how the next game UI automated testing carried out.

1, clear functional logic module UI Automation

Generally only fighting game features a variety of uncertain logic modules, functional logic other auxiliary modules are relatively clear, such as login, mall, backpacks, settings, and other community related to ordinary commercial software is no different.

The ratio can easily implement UI for automated testing of these modules, and these auxiliary function modules of the total UI of the game is also very high, the UI test automation has a high value.

For these relatively clear logic function UI module, the implementation of automated testing is the lowest cost, almost no changes to the game code, can be achieved only UI test automation in a simple engine modifications.

2, a simple state machine compatibility testing UI Automation

Currently there are games for the compatibility test: a simple monkey test, event recording playback. But these two methods have significant drawbacks:

Simple monkey test:

Just randomly click UI, UI element property is no ability to obtain, and no UI drive capability, do not judge logic, UI depth of coverage is limited. Even simple login can not log on, not to mention the deeper UI.

Event recording Playback:

Be achieved by simple hardcode UI Automation event recording, playback, do not have the ability to obtain UI element properties, simply change occurs UI automation will lead to failure.

For lack of these two methods, the ability to take advantage of drive-based UI engine, it can open a sub-thread real-time detection of the current UI state, in the main thread to perform the functions applicable to the current state of the script to achieve a relatively stable state depending on the UI UI compatibility testing.

举个简单的例子:以UI状态来划分一般游戏中会有登录、公告、主界面、对局、结算等UI状态。

如果子线程检测到当前UI是登录,则主线程执行登录相关脚本;

如果子线程检测到当前UI是公告,则主线程执行公告相关脚本;

如果子线程检测到当前UI是主界面,则执行启动对局相关脚本;

如果子线程检测到当前UI是对局,则执行对局相关脚本(或monkey test或回放录制的脚本);

如果子线程检测到当前UI是结算,则执行结算相关脚本。

利用基于引擎的UI驱动能力,可以获取、操作UI元素,再结合一定的的逻辑判断就可以覆盖更多/更深的UI,非常适合兼容性测试。

通过简单状态级实现兼容测试UI自动化也几乎不需要改动游戏代码,只在引擎一级简单修改就可以实现。

3、结合接口实现实时性要求比较低的游戏的UI自动化

对于一些卡牌类游戏或者实时性要求不高的游戏,由于UI比较简单,战斗交互不复杂,实时性要求并不高。结合开发人员或者测试人员实现的一些接口,再加上基于引擎的UI驱动能力就可以实现功能测试的UI自动化。

如果有了关卡数据获取接口,通过该接口在进入战斗前获取到关卡数据,再结合战斗过程中的UI表现,通过一定的逻辑判断就可以实现战斗过程的UI自动化。

如果有了结算数据获取接口,通过该接口在战斗结束后获取该局的结算数据,再获取结算UI显示数据即可以验证结算结果UI显示是否正确。

这种方式只需要游戏提供接口,可能会需要改动游戏代码,如果通过协议截获的方式对游戏程序影响最小,那么对UI的驱动基本不需要改动游戏代码,只在引擎一级简单修改即可实现。

4、结合AI实现实时性要求很高的游戏的UI自动化

对于一些复杂的,对实时性要求很高的动作类游戏,比如格斗、射击类游戏,则建议结合AI来实现UI自动化测试。AI实现对实时性要求很高的战斗过程的自动化,并对外提供接口用以获取战斗数据。

利用基于引擎的UI驱动能力实现其他模块的自动化,结合AI实现战斗模块的自动化,从而实现整个游戏的UI自动化测试。


可能会有人认为:既然有了AI,就可以完全用AI实现自动化测试。

但是UI自动化测试不仅仅需要UI驱动能力,还需要自动化测试框架提供调度、执行、统计、展示等功能,这些功能显然不适合让AI来实现。AI最适合实现战斗的驱动及对外提供游戏数据获取接口。AI一般集成在游戏内部,显然不适合用来完成整个游戏的自动化测试功能。


结合AI实现的UI自动化成本是最高的,需要开发AI代码,好在一般具有一定规模的游戏开发团队也都会自己开发AI来做一些开发自测或者作为内挂提供游戏托管功能,所以只需要在这些已有的AI上扩展一些功能即可,成本也是可控的。

以上就是我对游戏UI自动化测试的一些想法,各个游戏可以根据各自项目的情况有选择性的实施投入产出比可控的UI自动化测试。


抛砖引玉,欢迎拍砖!

登录优测官网,体验高效能测试服务


Guess you like

Origin blog.51cto.com/14652106/2462145