I. Script Packaging with Firebase¶
Note
The packaging function of the current IDE is under redevelopment. If you find it unable to use this function, please stop trying again. In addition, packaging the script into an APK does not mean that it can be detached from ADB. The packaged script still depends on ADB.
1.Precautions¶
Many users are interested in the scripts packaging function of Firebase, but not all scripts can be packaged. The following are some limitations of the packaging function. We hope that users can have a brief idea of the applicable scenarios of this function before using it at their discretion.
- The Poco of native Android apps cannot be packaged because it is not possible to launch another app from one app. However, Poco of game engines can be packaged.
- Some of the Airtest APIs cannot be executed using this method, such as:
clear_app
install_app
uninstall_app
- Due to the appearance of the Kivy splash screen image when launching the script, please open the application to be tested in the script. To do it, your script should start with start_app().
- When packaging scripts, do not use the directory of the target package because it involves some file deletion. Some users habitually open the command line for installation in the directory where the package is generated, which will lead to failure in the next packaging process.
2.Introduction to Firebase¶
The AirtestProject development team has collaborated with Google-Firebase to provide support for running test scripts on the Firebase cloud testing platform. The AirtestIDE currently integrates with the Firebase plugin, providing a testing mode where test scripts can be packaged into an APK and then run on a mobile device through instrumentation.
We can understand through the following diagram how the Firebase package runs test scripts on mobile phones.
Note: Rectangles represent test APKs; pentagons represent game APKs; blue fonts represent Python code; black fonts represent Java code. Next, let's take a look at how to build an instrumentation package in Airtest-IDE and run it on a mobile device.
3.Packaging Environment Configuration¶
Since the packaging process requires the use of the jarsigner module from the JDK being used, in order to use the Firebase packaging function in AirtestIDE, it is necessary to configure the Java (JDK, not JRE) environment (APK package needs to be re-signed):
After installing JDK, we need to configure the environment variables:
After the installation and configuration, type jarsigner
in the command line. If no error occurs in the command line, we are done with the environment configuration and can start packaging.
4.Packaging Process¶
-
Debug the test scripts in AirtestIDE.
-
Click on the drop-down menu "Firebase"-"Build Instrumentation Test Apk" to package a single script. Click on the drop-down menu "Firebase"-"Multiple Scripts Build" to package multiple scripts. The packaging order will follow the scripts order from top to bottom:
- When the packaging is completed, AirtestIDE will inject the test script and Python environment into the APK package and perform re-signing.
- After the script is packaged, click on the "open" button to open the path where the APK is located.
5.Running the Test Script¶
- Install the packaged test script APK together with the application to be tested on the phone.
- Then use the ADB command to run the test script:
adb shell am instrument -w com.netease.open.airbase/android.support.test.runner.AndroidJUnitRunner.