Running unit tests as part of your everyday Flutter workflow

Devon Carew
Flutter
Published in
2 min readMar 6, 2018

So you have gotten started with Flutter, have your app prototype up and running, and have started thinking about how you’d test your app. This guide will give you the quick and dirty of how to run and debug your tests.

The good news is that you already have a helpful starting example of a Flutter unit test! The flutter create template ships with a sample unit test:

You can see that it verifies the behavior of the counter for the sample app. You may not have noticed the ‘run’ icons in the editor’s gutter:

This is the Flutter plugin parsing your unit test code and inserting handy ‘run test’ actions directly into your editor. From IntelliJ or Android Studio, click on the ‘run’ icon and select either the option to run or debug your test:

The tests will run, and the results will be displayed in the standard IntelliJ test result view:

To debug your test, just set a breakpoint where you’d like to pause the test and select the Debug ‘test…’ option from the editor’s gutter run action. Your test will run and break at the breakpoint, letting you inspect variables and step through the code.

VS Code

If you develop with VS Code, follow issue #636 to track progress in adding support for flutter test tests there. You can also show your interest by added a thumbs up to the issues! It’ll help with prioritizing among feature requests.

For more info…

That’s it! For more info about testing your Flutter apps, see:

--

--