Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to create Flutter tests using Github Actions

Amey Sunu

Github actions

Github Actions automate your workflow to maintain the app integrity and avoid any code breakage during production.

Creating workflows

  • To add workflow to your existing Flutter repository, simply choose Actions.

  • Create a new workflow: You’ll see many pre-designed workflows for various services, right from AWS to Kubernetes, depending on the type of repository you are on.

  • Click on setup a workflow yourself, and it will create a predefined .yml file. You can even rename your workflow if you’d like.

  • Delete the contents of the .yml file and paste the following code below:

name: Flutter Test
    branches: [ master ]
    branches: [ master ]


    runs-on: ubuntu-latest

      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
          distribution: 'zulu'
          java-version: '11'
      - uses: subosito/flutter-action@v1
          flutter-version: '2.0.5'

      - name: Get all Flutter Packages
        run: flutter pub get

      - name: Run Flutter Test
        run: flutter test
  • In the script above, the name would be your workflow name. The on command handles when the workflow shall be triggered on pushing the code, and pull_request will trigger the workflow when a pull request is triggered.

  • In branches, you can specify which branch of the code you would want to reflect the push or pull changes and run the workflow.

  • The jobs is where you would define the workflow jobs that would execute it. In our instance, it would run on an Ubuntu machine. The same can be replaced with a Mac, Windows, or even any other Linux OS.

  • The steps is the set of steps that it needs in order to execute/install the needed pre-requisites. Here, we are installing Java and a Flutter action that was previously created for GitHub Actions.

  • The run will execute the workflow commands. Since we are merely just running the test command to test our Flutter project, we shall just use the flutter test.

  • Now, whenever you push or create a pull request from the master branch, the Github workflow will be triggered and would be automatically checking for tests.



View all Courses

Keep Exploring