title: Flutter Integration Tests with Travis CI
body: <h1>1. The Summary of the Problem</h1>
  
  <p>I would like a Travis CI setup that would let me run <code>flutter driver</code> tests inside an Android and an iOS environments. For this to happen, I expect I somehow have to install Flutter, Android and iOS in different environments.</p>
  
  <h1>2. What I Have So Far</h1>
  
  <p>Most of the posts I've been able to find on this topic are terribly outdated or feature incredibly complicated setups. Some of those that keep on appearing in my searches are:</p>
  
  <ul>
  <li><p><a href="https://medium.com/flutter/test-flutter-apps-on-travis-3fd5142ecd8c" rel="nofollow noreferrer">Test Flutter apps on Travis</a>, by Yegor Jbanov. This one covers unit and widget testing (<code>flutter test</code>), but not integration tests. </p>
  
  <ul>
  <li><p>It's from early 2017 and Travis CI has maybe simplified its API, because I've managed to make it work with only this:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>language: dart
  
  dart:
    - stable
  
  dart_task:
    - dartfmt
  
  install:
    - git clone https://github.com/flutter/flutter.git -b stable
  
  script:
    - ./flutter/bin/flutter doctor
    - ./flutter/bin/flutter test
  </code></pre></li>
  </ul></li>
  <li>One resource that I've found very useful is the <a href="https://github.com/flutter/samples/blob/master/.travis.yml" rel="nofollow noreferrer"><code>.travis.yml</code> in the Flutter samples repo</a>. The setup there seems very complicated to me though.</li>
  <li>The closest I could get to what I wanted is similar to Maurice McCabe's <a href="https://medium.com/@nocnoc/flutter-unit-widget-and-integration-testing-with-ios-and-android-emulators-on-travis-ci-df17ed7c3be" rel="nofollow noreferrer">Flutter unit, widget and integration testing with IOS and Android emulators on Travis-CI</a>.
  
  <ul>
  <li>Again, this seems overcomplicated and outdated.</li>
  </ul></li>
  </ul>
  
  <h1>3. The Sketch of What I Have in Mind</h1>
  
  <p>The <code>script</code> and <code>install</code> steps in the example I mentioned previously could be replaced by <code>jobs</code> with <code>stage</code>s. In this way, each stage would represent one sort of step. Unit and Widget stages in one, integration tests on Android and iOS in two others, which is similar to what Maurice McCabe and Flutter samples show. For example:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>jobs:
    include:
      - stage: Flutter Test
        language: dart
        os: linux
        install: git clone $FLUTTER_GITHUB -b stable
        before_script:
          - ./flutter/bin/flutter doctor
        script: 
          - ./flutter/bin/flutter test
      - stage: Integration Test on Android
        os: linux
        dist: trusty
        language: android
        android: # the things here are what probably needs to be fixed
          components:
            - build-tools-28.0.3
            - android-28
        install: git clone $FLUTTER_GITHUB -b stable
        before_script:
          - ./flutter/bin/flutter doctor
        script: 
          - ./flutter/bin/flutter drive --target=test_driver/app.dart
  </code></pre>
  
  <p>If I could create a <code>stage</code> for the <code>dartfmt</code> task that would also be nice in terms of organization.</p>