android 模拟器测试_使用android模拟器容器进行连续测试

android 模拟器测试

Setting up and running the Android Emulator on continuous integration (CI) or deployment (CD) is now easier than ever before with our pre-built Android Emulator Containers. These containers allow you to find and run the right version of the Emulator without the headache of dependency management, which makes it easy to scale automated tests as part of a CI/CD system without the upkeep cost of a physical device farm.

现在,借助我们预先构建的Android Emulator Containers,在持续集成(CI)或部署(CD)上设置和运行Android Emulator变得比以往更加容易。 这些容器使您能够查找并运行正确版本的仿真器,而不必担心依赖关系管理,这使得在CI / CD系统中轻松扩展自动化测试成为可能,而无需增加物理设备场的维护成本。

Earlier this year, we released Android Emulator download and Docker image generator scripts to help developers deploy and debug remote emulators. These scripts made it easier to find the right system image, manage system dependencies, and run the Android Emulator.

今年早些时候,我们发布了Android Emulator下载和Docker映像生成器脚本,以帮助开发人员部署和调试远程仿真器。 这些脚本使查找正确的系统映像,管理系统依赖关系和运行Android模拟器变得更加容易。

We are now taking this one step further and experimentally providing pre-built Android Emulator Containers for each major Emulator release. These containers remove the need to manually run the generator yourself, saving time and complexity. Don’t worry, the pre-built containers still support all of the features offered by those built with the Docker scripts, like adb and web access.

现在,我们将更进一步,通过实验为每个主要的Emulator版本提供预构建的Android Emulator Containers 。 这些容器使您无需亲自手动运行生成器,从而节省了时间和复杂性。 不用担心,预构建的容器仍然支持使用Docker脚本构建的容器提供的所有功能,例如adbWeb访问。

Linux KVM is required to run these containers and can be enabled by running on bare metal or on a virtual machine with nested virtualization. The correct option depends on your cloud provider, so read our documentation for recommendations.

运行这些容器需要Linux KVM ,并且可以通过在裸机或具有嵌套虚拟化功能的虚拟机上运行来启用Linux KVM 。 正确的选项取决于您的云提供商,因此请阅读我们的文档以获取建议。

The script below is an illustration of how you can integrate an Android Emulator Container into your system and use it to run tests.

以下脚本说明了如何将Android Emulator Container集成到系统中并使用它运行测试。

#!/bin/bash


# This is the remote image we are going to run.
# Docker will obtain it for us if needed.
DOCKER_IMAGE=us-docker.pkg.dev/android-emulator-268719/images/r-google-x64:30.0.23


# This is the forwarding port. Higher ports are preferred as to not interfere
# with adb's ability to scan for emulators.
PORT=15555


# This will launch the container in the background.
container_id=$(docker run -d \
  -e "ADBKEY=$(cat ~/.android/adbkey)" --device /dev/kvm --publish \
  8554:8554/tcp --publish $PORT:5555/tcp  \
  $DOCKER_IMAGE)


echo "The container is running with id: $container_id"


# Note you might see something like:
# failed to connect to localhost:15555
# this merely indicates that the container is not yet ready.


echo "Connecting to forwarded adb port."
adb connect localhost:$PORT


# we basically have to wait until `docker ps` shows us as healthy.
# this can take a bit as the emulator needs to boot up!
echo "Waiting until the device is ready"
adb wait-for-device


# The device is now booting, or close to be booted
# We just wait until the sys.boot_completed property is set to 1.
while [ "`adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ;
do
  echo "Still waiting for boot.."
  sleep 1;
done


# Now you can use the emulator as usual for example:
# ./gradlew installDebug
# ./gradlew connectedAndroidTest
# etc..


echo "The device is ready"
echo "Run the following command to stop the container:"
echo "docker stop ${container_id}"

Check out our general README for further information on getting started and taking advantage of the Android Emulator Containers. This is our first time offering pre-built Emulator Containers, so please report any problems or feature requests on our issue tracker.

查看我们的常规自述文件,以获取有关入门和利用Android模拟器容器的更多信息。 这是我们首次提供预构建的仿真器容器,因此请在问题跟踪器上报告任何问题或功能要求。

翻译自: https://medium.com/androiddevelopers/continuous-testing-with-android-emulator-containers-95d89a3ea270

android 模拟器测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值