Reputation: 615
Visual Studio Code does not recognize unit tests grouped in group(...)
. But it recognizes unit tests which are not grouped. I mean they are standalone test(...)
. I want to use group, because I need setUp()
.
There is Run | Debug
link above group
. When I click Debug or Run the Debug console shows No tests match regular expression "^LocalRepository$".
The tests are running correctly with flutter test
command.
Dart SDK: >=2.1.0 <3.0.0
Flutter channel: master
Edit: I found workaround - I just don't use group
callback. But I can't run all tests by clicking Run
above group
.
Upvotes: 21
Views: 11099
Reputation: 657048
Ensure the test has a name different from ''
Change
test('', () {
...
});
to
test('xxx', () {
...
});
Upvotes: 1
Reputation: 634
Make sure you name you test file ending with _test.dart
and you will see the run | debug options
Upvotes: 51
Reputation: 121
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.
Upvotes: 12
Reputation: 42333
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!
Upvotes: 1