How can you make sure that an app does exactly what it should do without any weird unexpected surprises? Well, you test it, of course. You could test everything manually by launching the app, using it, and trying your best to make the app blow up with errors. Or you can write a bunch of automated tests, which is arguably a more time-efficient and thorough way to test your apps. Let’s take a look at unit, widget, and integration tests in the video tutorial above.

Code snippets

VS Code snippets

  "Basic test scaffolding": {
    "prefix": "t_scaffold",
    "body": [
      "import 'package:flutter_test/flutter_test.dart';",
      "void main() {",
      "  late ${1:ClassName} sut;",
      "  setUp(() {",
      "    sut = ${1:ClassName}();",
      "  });",
      "  group('', () {});",
    "description": "Basic test scaffolding"
  "Test following the Arrange-Act-Assert pattern": {
    "prefix": "aaaTest",
    "body": ["test(", "  \"$1\",", "  () async {", "    $2", "  },", ");"],
    "description": "Test following the Arrange-Act-Assert pattern"

About the author 

Matt Rešetár

Matt is an app developer with a knack for teaching others. Working as a Flutter freelancer and most importantly developer educator, he doesn't have a lot of free time 😅 Yet he still manages to squeeze in tough workouts 💪

You may also like

  • Snippets for Android Studio:
    For t_scaffold:

    import ‘package:flutter_test/flutter_test.dart’;

    void main() {
    late $NAME$ sut;

    setUp(() {
    sut = $NAME$();

    group(”, () {});
    For aaaTest:
    () async{

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}