VS Code does not recognize unit tests in Flutter VS Code does not recognize unit tests in Flutter flutter flutter

VS Code does not recognize unit tests in Flutter


Make sure you name you test file ending with _test.dart and you will see the run | debug options


I have a Flutter project with two separate test files, both ending in "..._test.dart".

Using the following two test scenarios, one of the files passes, while the second doesn't load and that test fails.

Using launch.json configuration:

{ "name": "Dart: Run all Tests", "request": "launch", "type": "dart", "program": "./test/"}

Using the VS Code menu item Debug > Start Debugging (F5), which I suspicion just uses the above launch.json configuration, yields the same result.

However, using the VS Code menu item Debug > Start Without Debugging (Ctrl+F5), or "flutter test" from the command line, both tests pass.

I suspect this is an internal configuration issue with the VS Code Dart/Flutter extension, as opposed to a problem with Dart/Flutter code structure.


Are your tests/groups spread across multiple files? There are some limitations to the integration between the VS Code extension and the test package that you may be hitting.

There was a fix in v2.23 (released a few days before your question) that should have improved this a little (removing those Run/Debug links in some places they wont' work) but if you're already on that version then maybe it didn't cover your case.

If you can post a small repro on GitHub I'd definitely like to see if I can improve this. Thanks!