How to Use Tags in Your Unit and Widget Tests

Ever wanted to filter tests so you only run the ones you need to?

This can be easily done using test tags.

Super useful when you have dozens/hundreds of tests and you want to target specific ones from the command line. 👇

Example Code

import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets( 'Golden image test', (tester) async { await tester.pumpWidget(const MyApp()); await expectLater( find.byType(MyApp), matchesGoldenFile('golden_image.png'), ); }, tags: ['golden'], ); }

Configuration Options

Tags are quite flexible and you can use them to tag:

  • an entire test suite (with the @Tags annotation)
  • a test group or an individual test (with the tags argument, as shown above)

More info on the test package documentation:

Want More?

Invest in yourself with my high-quality Flutter courses.

Flutter In Production

Flutter In Production

Learn about flavors, environments, error monitoring, analytics, release management, CI/CD, and finally ship your Flutter apps to the stores. 🚀

Flutter Foundations Course

Flutter Foundations Course

Learn about State Management, App Architecture, Navigation, Testing, and much more by building a Flutter eCommerce app on iOS, Android, and web.

Flutter & Firebase Masterclass

Flutter & Firebase Masterclass

Learn about Firebase Auth, Cloud Firestore, Cloud Functions, Stripe payments, and much more by building a full-stack eCommerce app with Flutter & Firebase.

The Complete Dart Developer Guide

The Complete Dart Developer Guide

Learn Dart Programming in depth. Includes: basic to advanced topics, exercises, and projects. Last updated to Dart 2.15.

Flutter Animations Masterclass

Flutter Animations Masterclass

Master Flutter animations and build a completely custom habit tracking application.