Question

I am trying to find a solution for doing automation testing on iPad for a project that compiles from Unity3d.

Currently, I have some tests built with the Instruments UIAutomation tool. While I can drive the app and take screenshots, it seems like the objects on screen are not visible to the tool because of how they are generated from Unity, and not from Xcode itself. I've tried checking what objects are visible with the

logElementTree()

function, but all it returns is a rect object with a static image (including the buttons and things I would like to be able to access, but the program does not recognize as xcode objects). Creating tap and drag events only work with absolute positions on the screen; they do not find the elements themselves, so there is no way of doing any actual testing actions and states. Simulating any gameplay relies on a considerable amount of blind-faith procedure and implicit waiting, which pretty darn far from robust.


In a nutshell: I'm looking for an automated testing solution that will give me the ability to interact with objects created by Unity3d (which UIAutomation seems unable to do), and can be run on the iOS device itself. If anyone has experience with Unity3d iOS projects, I would really appreciate hearing about what solutions they use to get this functionality.

Was it helpful?

Solution

As much as I wish this was a simple task I dont think it will be.

Essentially unity has only one native iOS UI Element and that is the main view which takes up the entire screen.

The only way I can think that an automation system can be put together is by asking unity itself where things are within the screen so you can simulate the events with the X:, Y: Coordinates.

UIATarget.localTarget().tap({x:100, y:200});

but to do this you will likely need to build a native plugin for unity.

Native plugins are not horribly complicated, but they do require an intelligent design and a specific setup for each operating system.

Here is a link to a playlist with a few iPhone native plugin videos that will walk you through the process of building a native plugin where you can interface into Objective-C code.

SuperLazyCoder Youtube Playlist Watch this video and the next 2 to get the full idea about iPhone plugins

The rest is a matter of putting together a unity script that can convert your objects into Screen Coordinates and piping those back to your test application.

Hope that helps :) I would be eager to see the outcome.

OTHER TIPS

You can try this tool: Unity UI automation

It's similar to Appium, and allow to use Selenium for write tests

You could try AltUnity Tester. It's a free UI test automation tool that helps you interact with objects from a Unity game. It basically opens a TCP socket connection on the device running the application and gives access to all the objects from the Unity hierarchy.

It allows you to run tests on real devices(including iOS) or inside the Unity Editor. It supports tests written in C#, Python or Java.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top