Skip to content

Add an option to treat '_test.dart' files outside of './test' as tests #2160

@maxlapides

Description

@maxlapides

As a convention, we are keeping our test files next to our source files instead of in a separate test directory. Now, when we click "Run" above the test in VSCode, it fails:

Could not find an option named "name".

Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
Exited (64)

You can reproduce this:

  1. Create a new Flutter project
  2. Add a new file lib/main_test.dart:
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('test test', () {
    expect(123, 123);
  });
}
  1. Click "Run" above test
  2. Check Debug Console

Is there any way to get this working? If not, how do you recommend structuring the test directory? We have a very big project and we want to make sure we keep our code organized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in testingRelates to test execution of Dart/Flutter tests for end usersis bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions