[PYTHON] Airtest, one question at a time. Unity app E2E test starting with Airtest and Poco

This article is a 12/20 article of Sumzap Advent Calendar 2019 # 1.

What is Airtest

https://airtest.netease.com/ Cross platform UI automation IDE developed and published by NetEase. Here, we will call it a general term for IDEs and projects for automatic testing of mobile applications that use image recognition. By using this, you can create test code without knowing the code on the project directly. You can mass-produce the test as if it were an E2E test, or as an aging test, repeat the same actions endlessly. It is also suitable for such work.

What is Poco

https://github.com/AirtestProject/Poco Among the automated tests like Airtest, this library focuses on Unity's GUI. By incorporating Poco into your Unity project, you will be able to reference the UITree.

Airtest_IDE_v1_2_2_____Users_v00136_Desktop_untitled_air_untitled_py.png

merit

Demerit

Question one answer

How it works on Android

https://github.com/AirtestProject/Airtest/tree/master/airtest/core/android You can see the structure mainly by reading the source code group here.

We send minicaps on Android, receive images from minicaps, and send tap data. https://github.com/openstf/minicap https://openstf.io/ By the way, minicap is one of the projects published by CyberAgent, and it takes and sends high-speed screen captures in the Android device.

How it works on iOS

libimobiledevice(https://github.com/libimobiledevice) You can get images with this tool. This is a tool that is also used in Flutter's iOS build. Furthermore, tap information etc. goes through XcTest.

https://airtest.netease.com/docs/en/1_quick_start/3_get_started_with_iOS_test.html

For that purpose, we have prepared a test project. No, it's quite a skill. But with this method, you can control the terminal from the home screen, so it's quite a good E2E test.

Introduction of Poco

https://github.com/AirtestProject/Poco-SDK/tree/master/Unity3D Install this and delete the unused GUI directory.

And if you attach a manager like this.

var pocoGameObject = new GameObject();
pocoGameObject.name = "Poco";
pocoGameObject.gameObject.AddComponent<PocoManager>();

I want to take a video.

Depending on the environment, the following APIs can help you with Android. The usage in UnitTest will support the implementation. https://github.com/AirtestProject/Airtest/blob/master/airtest/core/android/recorder.py

I want to run it as a UnitTest.

Poco's operation is heavy.

The operation tends to be particularly heavy on screens where the amount of GameObject is large and the parameters of location information change frequently (for example, displaying a character in Live2D). Consider using freeze. https://poco.readthedocs.io/en/latest/source/doc/poco-example/optimize_speed_by_freezing_UI.html

When freeze is used, the location of the UI at the moment when freeze () is used is retained, so communication with the application side does not occur. You can send input at high speed. However, if the location of the UI changes (scrolling or moving UI), it is necessary to consider the timing and location of freeze ().

self.freeze = self.poco.freeze()
#The button UI usually doesn't "move" so get it from freeze
#However, please note that it is not possible to judge "whether or not" on the screen.
self.attack_button = self.freeze("attack_button")

I want to control multiple units at the same time.

#Simply specify the number of terminals.
_serial   = "Android:///hogehoge"
dev       = connect_device(self._serial)
poco = UnityPoco(port, device=dev)

How are you going to use it in your actual project?

It can be used by QA who do not have programming knowledge. We have created a mechanism to describe the order of actions in CSV etc.

For example, change the battle to a specific rule. Check the parameters after using a specific technique. Etc. are as follows. The rest is the stage of mass-producing such CSV and automating the checks that QA used to do manually.

tag,param,param2
The end of the war,,ID
Rule change,,Four limits&Healing disturbance&Solo rendition&Angry hair revenge&Strategic Kojin&Shugo Hayashi&Heavenly power&Mysterious versatility
War begins,,IDvsID
Game transition,hoge,Transition from game start to battle start
Cheering,Unlucky return,1
Spreadsheet input,A2,none
Status change,,ID&0
Status change,,ID&20
Cheering,Unlucky return,1
Spreadsheet input,B2,none

That's why I sent you an introduction to Airtest and Poco. Depending on the idea, in combination with machine learning, you do not have to specify the buttons in detail Debugging proceeds. I think I can do anything, I would like to work on it. I hope you can exchange various information.

Tomorrow is an article by @mikami_akihisa.

Recommended Posts

Airtest, one question at a time. Unity app E2E test starting with Airtest and Poco
Strengthen with code test ⑦
Strengthen with code test ⑨
Strengthen with code test ③
Strengthen with code test ⑤
Strengthen with code test ②
Strengthen with code test ①
Strengthen with code test ⑧
Strengthen with code test ⑨
Test automation starting with L-Chika (3) Oscilloscope integration
How to start the code written in Atom with one command without starting teminal
Airtest, one question at a time. Unity app E2E test starting with Airtest and Poco
Test automation starting with L-Chika (5) Webcam and OCR integration
Let's make a Mac app with Tkinter and py2app
Take a look at profiling and dumping with Dataflow