Home > Enterprise >  How to specify test tags correctly in dart_test.yaml?
How to specify test tags correctly in dart_test.yaml?

Time:07-19

I have a dart project that has several tests, when I try to run an isolated test I get this warning:

Warning: A tag was used that wasn't specified in dart_test.yaml. "tagName" was used in the suite itself

how should i declare these tags correctly in dart_test.yaml?

CodePudding user response:

Steps

  1. Create a file dart_test.yaml at the root of your project
  2. Add your tags one after another under a tags field
  3. Add tags to your test or testWidget declaration
  4. Run your tests with the -t flag followed by the wanted tag

Sample

Let's say I want to add the following tags: golden, atom, molecule, organism, mobile, desktop. My dart_test.yaml will look like this:

tags:
  golden:
  atom:
  molecule:
  organism:
  mobile:
  desktop:

And everything should be okay you can write your test:

void main() {
  testWidgets(
    'this is a test',
    (tester) async {
      // ...
    },
    tags: ['atom', 'mobile'],
  );
}

You can run it with the following command:

$ flutter test -t mobile

source

  • Related