Skip to content

Generate working main() methods in test files #3582

@athomas

Description

@athomas

Is your feature request related to a problem? Please describe.
When you create a new test file for use with package:test, you need a main method without arguments (e.g. void main()). However, the main template in vscode will insert void main(List<String> arguments) {.... The analyzer can't find an issue with that because it's a valid main method. However, running the tests fails because package:test barfs at the main method.

Describe the solution you'd like
A context aware template that inserts the main method with arguments in regular dart files but inserts a main method without arguments in _test.dart files. (Or alternatively, a second template that also comes up when you type main and inserts something appropriate for tests, perhaps even contains a bit more common test skeleton code like an actual test method or setUp/tearDown calls).

@pq

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions