-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run tests using line/col to support groups/test with dynamic names #4021
Comments
Currently there are some limitations because of how tests are run individually (by name). Without executing the tests, it's impossible for the extension to know what However, once you've run the test file, you should be able to run the tests from the explorer, or from the test icons in the gutter, because the previous runs names would have been captured.
I'll keep this issue open to track that, as it looks like there isn't an existing issue tracking it right now. |
Will running single tests/groups with dynamic descriptions via vs code be possible with this? |
@jtdLab I'm hoping so, but I haven't done much testing yet (and it may depend on the exact configuration of the test). If you have some specific tests in mind, you can try running them from the terminal using the line/col like:
Where line/col are where your test definitions are. If that runs them, then it should work here. If it doesn't work, please post an example and I can do some digging. |
@DanTup im thinking about a scenario like this foo_test.dart // I want to run this test via the vs code Run | Debug (even though it has no description)
rendersText(MyWidget(), text: 'Foo'); my_shared_testing_library.dart @isTest
void rendersText(Widget widget, {required String text}) {
testWidgets('renders $text', (tester) async {
// Some testing here
});
} Is this possible via line/col and not description? |
@jtdLab I would hope/expect that to work. You can test it by running |
@DanTup When running via the clickable Run | Debug above the test on |
@jtdLab that's expected right now, using line/col has not been implemented in the extension yet. You can use |
@DanTup Perfect thank you a lot |
@DanTup Let |
I tested this using latest Flutter master (I missed you were using Flutter, so it should've been So at least for a future version of Flutter, once this is implemented I believe what you're after works. (I tested it with |
Started looking at this, but think we may be blocked on:
How to proceed will depend a little on the response to the |
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! |
Added by @DanTup:
Some test cases to ensure are handled:
Describe the bug
I have some functions to give a specific format to the descriptions of the groups and tests, like indentation, in this way it is easier to read them in the console, but when I execute a specific test, giving run in that group or test it tells me:
To Reproduce
this is a minimal example:
If you press run or debug on a specific group or test, you can see the error, an also in the testing tab you can see that the names are the function instead of the real test name.

If you press run or debug on main, or use the command run all tests, it runs normal but also in the testing tab keep the names are the function instead of the real test name, and now also the real tests names.
Thank you.
Please complete the following information:
Operating System and version: Windows 10
VS Code version: 1.68.0
Dart extension version: 3.42.0
Dart/Flutter SDK version: flutter 3.0.1
The text was updated successfully, but these errors were encountered: