flutter app UI自动化测试

flutter run:下载依赖并安装APK
flutter install:安装apk
flutter pub get: 下载依赖
flutter doctor -v: 验证flutter环境配置

flutter开发环境配置

linux环境,可以使用下面的脚本自动配置开发环境(在ubuntu 16.04运行成功):

#使用flutter中国的镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

export ANDROID_HOME="/opt/android-sdk" \
export PATH="/opt/android-sdk/tools/bin:/opt/flutter/bin:/opt/flutter/bin/cache/dart-sdk/bin:$PATH"

#安装基本依赖
apt-get update \
&& apt-get -y install --no-install-recommends curl git lib32stdc++6 openjdk-8-jdk-headless unzip \
&& apt-get -y install lcov \
&& apt-get --purge autoremove \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/*

#下载flutter
git clone -b master https://github.com/flutter/flutter.git /opt/flutter

#下载android sdk
curl -O https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip \
&& mkdir /opt/android-sdk \
&& unzip sdk-tools-linux-4333796.zip -d /opt/android-sdk \
&& rm sdk-tools-linux-4333796.zip

#安装android sdk 特定版本
mkdir ~/.android \
&& echo 'count=0' > ~/.android/repositories.cfg \
&& yes | sdkmanager --licenses \
&& sdkmanager "tools" "build-tools;28.0.3" "platforms;android-28" "platform-tools" \
&& yes | sdkmanager --licenses \
&& flutter doctor -v

flutter doctor -v最后的输出有三个错误:


[✗] Chrome - develop for the web (Cannot find chrome executable at google-chrome)
    ! CHROME_EXECUTABLE not set

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is not installed
    ✗ make is not installed

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

安装chrome

#ddes
apt-get update
apt-get install apt-transport-https wget curl -y
wget http://www.linuxidc.com/files/repo/google-chrome.list -P /etc/apt/sources.list.d/
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub  | apt-key add -
set -x && apt-get update \
    && apt-get install -y \
        xvfb \
        google-chrome-stable

安装make和clang

$apt install clang-3.5
$apt install build-essential
$ln -s /usr/bin/clang-3.5 /usr/bin/clang++

再次运行flutter doctor -v可以看到原来的三个错误已经消失。

This package referenced a Flutter repository via the .packages file that is no longer available,删掉.package文件重新生成即可:

root@ubuntu:/home/pilot/flutter_integration_test# flutter run
+ flutter run
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.
  /
Warning! This package referenced a Flutter repository via the .packages file that is no longer available. The repository from which the 'flutter' tool is currently executing will be used instead.
  running Flutter tool: /opt/flutter
  previous reference  : /D:/flutter/flutter
This can happen if you deleted or moved your copy of the Flutter repository, or if it was on a volume that is no longer mounted or has been mounted at a different location. Please check your system path
to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your path).


No supported devices connected.
root@ubuntu:/home/pilot/flutter_integration_test# vim .packages
+ vim .packages
root@ubuntu:/home/pilot/flutter_integration_test# cp .packages .packages2
+ cp .packages .packages2
root@ubuntu:/home/pilot/flutter_integration_test# rm -rf .packages
+ rm -rf .packages
root@ubuntu:/home/pilot/flutter_integration_test# flutter run
+ flutter run
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.

dockerfile

root@ubuntu:~/flutter# cat Dockerfile
FROM docker.jiuxia.com/flutter:2.0

RUN apt-get update
RUN apt-get install -y pulseaudio
RUN apt-get install -y libglu1
RUN /opt/android-sdk/tools/bin/sdkmanager --install emulator

使用Appium

flutter的源代码部分:

@override
  Widget build(BuildContext context)
  {
    return new Material(
      color: Colors.blue,
      child: new InkWell(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            new Text("Hello World!",  style: new TextStyle(color: Colors.white, fontSize: 30.0),),
          ],
        )
      ),
    );
  }
}

使用ui automater viewer看到的效果:


flutter app UI自动化测试_第1张图片
image.png

flutter无法添加自定义属性字段,只能使用xpath定位界面上的控件。

appium脚本尝试获取界面上的"hello world”

# coding=utf-8
from appium import webdriver
import unittest
import time

class TestFluter(unittest.TestCase):

    def setUp(self):
        desired_caps = {
            'platformName': 'Android',
            'platformVersion': '8.0.0',
            'deviceName': 'A5RNW18316011440',
            'appPackage': 'com.example.helloworld',
            'appActivity': '.MainActivity',
            'automationName': 'Appium',
            'unicodeKeyboard': 'True',
            'resetKeyboard': 'True',
        }
        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

    def tearDown(self):
        self.driver.quit()

    def test_plus(self):
        time.sleep(30)
        print('==================')
        t1 = self.driver.find_element_by_xpath("//*[@text='Hello World!']")
        print(t1.text)
        print('+++++++++++++++++++')

        time.sleep(10)



if __name__ == '__main__':
    si = unittest.TestLoader().loadTestsFromTestCase(TesXiaomiCalc)
    unittest.TextTestRunner(verbosity=2).run(si)

使用Flutter自带的测试框架

参考 https://flutter.dev/docs/cookbook/testing/integration/introduction

目录结构

flutter_integration_test/
  lib/
    main.dart
  test_driver/
    app.dart
    app_test.dart

pubspec.yaml

name: flutter_integration_test
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_driver:
    sdk: flutter
  test: any


flutter:
  uses-material-design: true

main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Counter App',
      home: MyHomePage(title: 'Counter App Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              // Provide a Key to this specific Text widget. This allows
              // identifing the widget from inside the test suite,
              // and reading the text.
              key: Key('counter'),
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        // Provide a Key to this button. This allows finding this
        // specific button inside the test suite, and tapping it.
        key: Key('increment'),
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

app.dart

import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_integration_test/main.dart' as app;

void main() {
  // This line enables the extension.
  enableFlutterDriverExtension();

  // Call the `main()` function of the app, or call `runApp` with
  // any widget you are interested in testing.
  app.main();
}

所有的测试脚本必须以_test结尾才能够被识别。脚本里识别控件是通过添加的key来实现的:
app_test.dart

// Imports the Flutter Driver API.
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
import 'dart:io';

void main() {
  group('Counter App', () {
    // First, define the Finders and use them to locate widgets from the
    // test suite. Note: the Strings provided to the `byValueKey` method must
    // be the same as the Strings we used for the Keys in step 1.
    final counterTextFinder = find.byValueKey('counter');
    final buttonFinder = find.byValueKey('increment');

    FlutterDriver driver;

    // Connect to the Flutter driver before running any tests.
    setUpAll(() async {
      driver = await FlutterDriver.connect();
    });

    // Close the connection to the driver after the tests have completed.
    tearDownAll(() async {
      if (driver != null) {
        driver.close();
      }
    });

    test('starts at 0', () async {
      // Use the `driver.getText` method to verify the counter starts at 0.
      sleep(const Duration(seconds: 5));
      expect(await driver.getText(counterTextFinder), "0");
    });

    test('increments the counter', () async {
      // First, tap the button.
      await driver.tap(buttonFinder);
      sleep(const Duration(seconds: 5));
      // Then, verify the counter text is incremented by 1.
      expect(await driver.getText(counterTextFinder), "1");
    });
  });
}

执行脚本

$ flutter drive --target=test_driver/app.dart
Running "flutter packages get" in flutter_integration_test...         0.5s
Using device FLA AL20.
Starting application: test_driver/app.dart
Initializing gradle...                                              0.6s
Resolving dependencies...                                           2.4s
Installing build\app\outputs\apk\app.apk...                         4.3s
Running Gradle task 'assembleDebug'...                              1.9s
Built build\app\outputs\apk\debug\app-debug.apk.
I/flutter ( 9874): Observatory listening on http://127.0.0.1:41353/
00:00 +0: Counter App (setUpAll)
[info ] FlutterDriver: Connecting to Flutter application at http://127.0.0.1:52914/
[trace] FlutterDriver: Isolate found with number: 880303057
[trace] FlutterDriver: Isolate is paused at start.
[trace] FlutterDriver: Attempting to resume isolate
[trace] FlutterDriver: Waiting for service extension
00:02 +0: Counter App starts at 0
[info ] FlutterDriver: Connected to Flutter application.
00:03 +1: Counter App increments the counter
00:03 +2: Counter App (tearDownAll)
00:03 +2: All tests passed!
Stopping application instance.

使用夜神模拟器安卓虚拟机

使用夜神模拟器的安卓虚拟机,执行上面的flutter测试脚本,可以正常运行并且得到同样的测试结果:

$ flutter drive --target=test_driver/app.dart
Using device google Pixel 2.
Starting application: test_driver/app.dart
Initializing gradle...                                              0.7s
Resolving dependencies...                                           2.6s
Installing build\app\outputs\apk\app.apk...                         3.9s
Running Gradle task 'assembleDebug'...                              2.0s
Built build\app\outputs\apk\debug\app-debug.apk.
I/flutter ( 3596): Observatory listening on http://127.0.0.1:43430/
00:00 +0: Counter App (setUpAll)
[info ] FlutterDriver: Connecting to Flutter application at http://127.0.0.1:54495/
[trace] FlutterDriver: Isolate found with number: 241353197
[trace] FlutterDriver: Isolate is paused at start.
[trace] FlutterDriver: Attempting to resume isolate
[trace] FlutterDriver: Waiting for service extension
[info ] FlutterDriver: Connected to Flutter application.
00:00 +0: Counter App starts at 0
00:05 +1: Counter App increments the counter
00:10 +2: Counter App (tearDownAll)
00:10 +2: All tests passed!
Stopping application instance.

使用vmware+ubuntu+真机执行测试脚本

在windows上安装vmware+ubuntu,在虚拟机里执行flutter UI测试脚本,可以找到外面的USB连着的手机,但很不稳定,有时候能找到有时候提示找不到,能找到的时候执行自动化脚本也会失败,提示说tap时间过长或者FlutterDriver: It is taking an unusually long time to connect to the VM

结论:有时候能成功,有时候会失败,有时候会HANG在那里提示说VM长时间没反应。

如果失败时,可以使用flutter -v drive --target=test_driver/app.dart查看详细的信息输出

使用windows+android studio自带的模拟器执行测试脚本

现在android sdk里已经不再包含图形界面的sdk manager了,图形界面的SDK manager集成到了android studio里,可以在tools菜单里找到。

通过android studio创建好安卓模拟器,启动模拟器。如果启动模拟器后在adb devices看到的模拟器是unauthorized状态,一般可以通过重启adb服务器来解决,如果还不行,可以通过模拟器的Wipe Data清除数据后再次尝试。默认情况下,打开模拟器,使用adb devices就能查看到online状态的模拟器。

启动模拟器并且状态是online后,执行上面的flutter自动化测试脚本,可以正常运行并输出结果。

使用无界面模式运行flutter UI自动化测试


#android命令已经过时,官方建议使用sdkmanager.bat
$ ./android.bat list target
**************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat
**************************************************************************

Invoking "C:\Users\Administrator\AppData\Local\Android\Sdk\tools\bin\avdmanager" list target

Available Android targets:==============] 100% Fetch remote repository...
----------
id: 1 or "android-27"
     Name: Android API 27
     Type: Platform
     API level: 27
     Revision: 3
----------
id: 2 or "android-28"
     Name: Android API 28
     Type: Platform
     API level: 28
     Revision: 6

#使用sdkmananger查看已安装的和未安装的
$ ./sdkmanager.bat --list
Warning: File C:\Users\Administrator\.android\repositories.cfg could not be loaded.
Installed packages:=====================] 100% Computing updates...
  Path                                                                              | Version | Description                                     | Location
  -------                                                                           | ------- | -------                                         | -------
  build-tools;27.0.3                                                                | 27.0.3  | Android SDK Build-Tools 27.0.3                  | build-tools\27.0.3\
  build-tools;28.0.3                                                                | 28.0.3  | Android SDK Build-Tools 28.0.3                  | build-tools\28.0.3\
  emulator                                                                          | 28.0.22 | Android Emulator                                | emulator\
  extras;android;m2repository                                                       | 47.0.0  | Android Support Repository                      | extras\android\m2repository\
  extras;google;m2repository                                                        | 58      | Google Repository                               | extras\google\m2repository\
  extras;intel;Hardware_Accelerated_Execution_Manager                               | 7.3.2   | Intel x86 Emulator Accelerator (HAXM installer) | extras\intel\Hardware_Accelerated_Execution_Manager\
  extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2 | 1       | Solver for ConstraintLayout 1.0.2               | extras\m2repository\com\android\support\constraint\constraint-layout-solver\1.0.2\
  extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2        | 1       | ConstraintLayout for Android 1.0.2              | extras\m2repository\com\android\support\constraint\constraint-layout\1.0.2\
  patcher;v4                                                                        | 1       | SDK Patch Applier v4                            | patcher\v4\
  platform-tools                                                                    | 28.0.1  | Android SDK Platform-Tools                      | platform-tools\
  platforms;android-27                                                              | 3       | Android SDK Platform 27                         | platforms\android-27\
  platforms;android-28                                                              | 6       | Android SDK Platform 28                         | platforms\android-28\
  sources;android-28                                                                | 1       | Sources for Android 28                          | sources\android-28\
  system-images;android-25;google_apis;armeabi-v7a                                  | 15      | Google APIs ARM EABI v7a System Image           | system-images\android-25\google_apis\armeabi-v7a\
  system-images;android-28;google_apis_playstore;x86                                | 8       | Google Play Intel x86 Atom System Image         | system-images\android-28\google_apis_playstore\x86\
  tools                                                                             | 26.1.1  | Android SDK Tools                               | tools\


#命令行创建android模拟器. -k参数后面跟的是镜像等信息,如果不知道现在又哪些镜像,可以随便写一个,它会输出目前已有镜像,也可以使用上面的sdkmananger --list来查看;windows上面,android.bat位于C:\Users\Administrator\AppData\Local\Android\Sdk\tools
#使用下面的命令创建模拟器,使用默认设置即可。创建好后执行flutter自动化测试脚本,可以看到可以正常执行成功;尽量不要使用带Google APIs字样的镜像,否则命令行启动模拟器的时候会报 PANIC: Missing emulator engine program for 'x86' CPU.
$android.bat create avd -n myEmulator -k system-images;android-28;default;x86_64

$ ./android.bat list avd
   Name: Galaxy_Nexus_API_25
  Device: Galaxy Nexus (Google)
    Path: C:\Users\Administrator\.android\avd\Galaxy_Nexus_API_25.avd
  Target: Google APIs (Google Inc.)
          Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/armeabi-v7a
    Skin: galaxy_nexus
  Sdcard: 512M
---------
    Name: myEmulator
    Path: C:\Users\Administrator\.android\avd\myEmulator.avd
  Target: Default Android System Image
          Based on: Android API 28 Tag/ABI: default/x86_64

The following Android Virtual Devices could not be loaded:
    Name: crazyit
    Path: C:\Users\Administrator\.android\avd\crazyit.avd
   Error: Missing system image for Google Play x86 crazyit.'
---------
    Name: Nexus_5X_API_28
    Path: C:\Users\Administrator\.android\avd\Nexus_5X_API_28.avd
   Error: Missing system image for Google Play x86 Nexus_5X_API_28.'

#命令行启动模拟器,并制定内存大小,不指定的话使用默认大小;启动模拟器后执行FLUTTER自动化脚本,可以正常执行
$emulator -avd crazyit -memory 512 &

#如果需要命令行安装,可以参考下面的方式
#首先通过--list查看可以安装的镜像,比如看到其中有system-images;android-28;default;x86 
root@ubuntu:/opt/android-sdk/tools/bin# ./sdkmanager --list
system-images;android-28;default;x86                                                     | 4            | Intel x86 Atom System Image
#安装
root@ubuntu:/opt/android-sdk/tools/bin# ./sdkmanager --install "system-images;android-28;default;x86"
[=======================================] 100% Unzipping... x86/build.prop
#确认已经安装好
root@ubuntu:/opt/android-sdk/tools/bin# ./sdkmanager --list
Installed packages:=====================] 100% Computing updates...
  Path                                 | Version | Description                    | Location
  -------                              | ------- | -------                        | -------
  build-tools;28.0.3                   | 28.0.3  | Android SDK Build-Tools 28.0.3 | build-tools/28.0.3/
  platform-tools                       | 29.0.1  | Android SDK Platform-Tools     | platform-tools/
  platforms;android-28                 | 6       | Android SDK Platform 28        | platforms/android-28/
  system-images;android-28;default;x86 | 4       | Intel x86 Atom System Image    | system-images/android-28/default/x86/
  tools                                | 26.1.1  | Android SDK Tools 26.1.1       | tools/

#接下来就可以使用刚才下载的镜像创建emulator了
root@ubuntu:/opt/android-sdk/tools/bin# ../android create avd -n myEmulator3 -k "system-images;android-21;default;x86"

#尝试启动,但报错
root@ubuntu:/opt/android-sdk/tools# ./emulator @myEmulator3
[139736297248576]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib
Could not launch '/opt/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-i386': No such file or directory
root@ubuntu:/opt/android-sdk/tools# cd bin
root@ubuntu:/opt/android-sdk/tools/bin# ls
apkanalyzer  archquery  avdmanager  jobb  lint  monkeyrunner  screenshot2  sdkmanager  uiautomatorviewer

#查找emulator并安装
root@ubuntu:/opt/android-sdk/tools/bin# ./sdkmanager --list| grep emulator
  emulator                                                                                 | 29.0.11      | Android Emulator
  extras;google;auto                                                                       | 1.1          | Android Auto Desktop Head Unit emulator
root@ubuntu:/opt/android-sdk/tools/bin# ./sdkmanager --install emulator
[=======================================] 100% Unzipping... emulator/NOTICE.txt
root@ubuntu:/opt/android-sdk/tools/bin# ls ../../
build-tools/    emulator/       .knownPackages  licenses/       patcher/        platforms/      platform-tools/ system-images/  tools/
root@ubuntu:/opt/android-sdk/tools/bin# ls ../../emulator/
android-info.txt          emulator64-crash-service  goldfish-webrtc-bridge    mksdcard                  qemu/                     source.properties
bin64/                    emulator-check            lib/                      NOTICE.txt                qemu-img
emulator                  emulator-headless         lib64/                    package.xml               resources/
root@ubuntu:/opt/android-sdk/tools/bin# ls ../../emulator/
android-info.txt  emulator                  emulator-check     goldfish-webrtc-bridge  lib64     NOTICE.txt   qemu      resources
bin64             emulator64-crash-service  emulator-headless  lib   

root@ubuntu:/opt/android-sdk/tools# ./emulator @myEmulator3
/opt/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-i386: error while loading shared libraries: libpulse.so.0: cannot open shared object file: No such file or directory
root@ubuntu:/opt/android-sdk/tools# ./emulator @myEmulator2
/opt/android-sdk/tools/../emulator/qemu/linux-x86_64/qemu-system-x86_64: error while loading shared libraries: libpulse.so.0: cannot open shared object file: No such file or directory

root@ubuntu:/opt/android-sdk/tools# apt-get install libpulse0:i386 pulseaudio


root@ubuntu:/opt/android-sdk/tools# ./emulator @myEmulator3
MobaXterm X11 proxy: Unsupported authorisation protocol
emulator: WARNING: encryption is off
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: KVM requires a CPU that supports vmx or svm
More info on configuring VM acceleration on Linux:
https://developer.android.com/studio/run/emulator-acceleration#vm-linux
General information on acceleration: https://developer.android.com/studio/run/emulator-acceleration.

#打开虚拟机设置里的虚拟相关设置后再次尝试
 root@ubuntu:/opt/android-sdk/tools#./emulator @myEmulator3 -no-skin -no-audio -no-window

在虚拟机(无图形界面的ubuntu 16.04)里启动模拟器后(此时的模拟器是没有任何界面的),可以用adb devices查看已经启动的emulator. 执行flutter的自动化测试脚本,可以看到可以正常运行并输出结果。

Troubleshooting

问题一:MobaXterm X11 proxy: Unsupported authorisation protocol

使用mobaxterm登录到虚拟机启动emulator时会报这个错,可以直接登录虚拟机不使用moba就不会报这个错了。尝试参考网上的方法解决mobaxterm这个问题,未果。

问题二:Run Android emulator without GUI (headless mode)

Emulator 28.1.8 is now available in the Canary and Dev channels. 自带的命令行工具分为emulator和emulator-headless, 其中的emulator-headless可以直接支持headless mode.

#对于Emulator 28之前的版本,可以使用如下方式启动不带界面的emulator
$emulator @myEmulator3 -no-skin -no-audio -no-window

#对于Emulator 28之后的版本,可以使用如下方式启动不带界面的emulator
$....
问题三:PANIC: Missing emulator engine program for 'x86' CPU

解决方法一:不要使用带有google api字样的镜像
解决方法二:尝试使用x86_64而不是x86的镜像

问题四:error while loading shared libraries: libpulse.so.0: cannot open shared object file
$apt-get install -y libpulse0:i386 pulseaudio
问题五:emulator: ERROR: x86_64 emulation currently requires hardware acceleration

先看一下如果有hardware acceleration的情形


root@ubuntu:/opt/android-sdk/emulator# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

root@ubuntu:/opt/android-sdk/emulator# ./emulator  -accel-check
accel:
0
KVM (version 12) is installed and usable.
accel
#检查是否支持hardware virtualization: egrep -c '(vmx|svm)' /proc/cpuinfo
root@ubuntu:/opt/android-sdk/emulator# ls /dev/kvm
/dev/kvm
root@ubuntu:/opt/android-sdk/emulator# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 60
model name      : Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
stepping        : 3
microcode       : 0x25
cpu MHz         : 4000.006
cache size      : 8192 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt arat
bugs            :
bogomips        : 8000.01
clflush size    : 64
cache_alignment : 64
address sizes   : 43 bits physical, 48 bits virtual
power management:

#但并没有安装qemu-kvm的包,大概不需要
root@ubuntu:/opt/android-sdk/emulator# kvm --version
The program 'kvm' is currently not installed. You can install it by typing:
apt install qemu-kvm

如果没有hardware acceleration:

#dd

References

https://www.cnblogs.com/cnkemi/p/9180525.html
https://blog.csdn.net/u011541946/article/details/77922304
https://www.cnblogs.com/tobecrazy/p/4596214.html
https://www.cnblogs.com/Lihao2013/p/6149733.html
https://medium.com/@husayn.hakeem/flutter-hello-world-d15032356c81
https://www.jianshu.com/p/363ff4f5d832
https://flutter.dev/docs/cookbook/testing/integration/introduction
https://appiumpro.com/editions/58
https://paulemtz.blogspot.com/2013/05/android-testing-in-headless-emulator.html
https://medium.com/@nocnoc/android-emulators-in-thcloud-f39e11c15bfa
https://learningnetwork.cisco.com/docs/DOC-30195
https://vitux.com/how-to-install-kvm-to-create-and-manage-virtual-machines-in-ubuntu/
https://developer.android.com/studio/run/emulator-acceleration
https://software.intel.com/en-us/blogs/2012/03/12/how-to-start-intel-hardware-assisted-virtualization-hypervisor-on-linux-to-speed-up-intel-android-x86-emulator

你可能感兴趣的:(flutter app UI自动化测试)