You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Having a group with an anonymous function with some calls to the test function, when I click on "Run" above an test function, somehow the argument passed to dart test has the group an test name and I'm able to run the test without problems.
But when I pass a reference to a function to the group, the argument passed to dart test has only the test name and I receive an No tests match regular expression error.
Describe the solution you'd like
This is more a question than an enchancement, so here it goes: Is it possible to run the First test in the example by clicking on "Run" above it?
I'm questioning because I don't know if there is a limitation on how VS Code handle this.
Additional context
Here is a sample code. In this example, I'm able to run "Second test" but not "First test".
Yes, this is an unfortunate limitation. The issue is that VS Code runs tests by providing the "full test name" (which is all groups+test name combined) to dart test. In your non-working example above, the structure of the file makes it seem like "First test" is the complete test name, but it's not so it does not match.
If we changed to not use the full test name, then there are issues with code like this:
group('foo', () {
test('does the expected', () {});
});
group('bar', () {
test('does the expected', () {});
});
If we only passed "does the expected" then both tests would run when you tried to run either.
However, there may be a solution in the near future. package:test has recently gained the ability to filter tests by line number too, so we could in theory pass a partial test name and the line number and I think that might resolve this. We'll need to do something to ensure the version of package:test is new enough to support this, but I think that's doable.
DanTup
changed the title
Run tests with referenced function
Support running single tests that are not inside their group hierarchy in the source file
Oct 26, 2021
In the next release (and the pre-release version just pushed today - v3.63.20240419), you can choose to have tests executed using their line numbers rather than their names. This fixes a number of issues including this one, caused by not always being able to statically compute the exact name of a test.
Please let me know if you find any issues with this functionality!
Is your feature request related to a problem? Please describe.
Having a
group
with an anonymous function with some calls to thetest
function, when I click on "Run" above antest
function, somehow the argument passed todart test
has the group an test name and I'm able to run the test without problems.But when I pass a reference to a function to the
group
, the argument passed todart test
has only the test name and I receive anNo tests match regular expression
error.Describe the solution you'd like
This is more a question than an enchancement, so here it goes: Is it possible to run the
First test
in the example by clicking on "Run" above it?I'm questioning because I don't know if there is a limitation on how VS Code handle this.
Additional context
Here is a sample code. In this example, I'm able to run "Second test" but not "First test".
And also the debug logs of both scenarios.
The text was updated successfully, but these errors were encountered: