Skip to content

20181226_docker testing with flutter sdk

Shawn Wang edited this page Apr 3, 2019 · 2 revisions

title: "用 Docker 整合測試 Flutter 框架" date: 2018-12-26 type: blog author: AppleBoy link: https://blog.wu-boy.com/2018/12/docker-testing-with-flutter-sdk/ layout: post comments: true

Flutter 是一套以 Dart 語言為主體的手機 App 開發框架,讓開發者可以寫一種語言產生 iOS 及 Android,只要裝好 Flutter 框架,就可以在個人電腦上面同時測試 iOS 及 Android 流程,如果您需要 Docker 環境,可以直接參考此開源專案,裡面已經將 Flutter 1.0 SDK 包在容器,只要將專案目錄掛載到 Docker 內,就可以透過 flutter test 指令來完成測試,對於 CI/CD 流程使用 Docker 技術非常方便。

線上影片教學

<iframe width="560" height="315" src="https://www.youtube.com/embed/80kiMR_Firs" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Docker 使用方式

下載 Docker Image,檔案有點大,先下載好比較方便

$ docker pull appleboy/flutter-docker:1.0.0

下載測試範例,並執行測試

$ git clone https://github.com/appleboy/flutter-demo.git
$ docker run -ti -v ${PWD}/flutter-demo:/flutter-demo -w /flutter-demo \
  appleboy/flutter-docker:1.0.0 \
  /bin/sh -c "flutter test"

使用 Drone 自動化測試

搭配 Drone Cloud 服務,在專案底下新增 .drone.yml,內容如下:

kind: pipeline
name: testing

steps:
  - name: flutter
    image: appleboy/flutter-docker:1.0.0
    commands:
      - flutter test
Clone this wiki locally