I'm working on a Flutter project and trying to find the best way to structure my tests. Typically I structure tests to mirror the directory structure of the main project which is being tested.
lib
|models
|providers
|userprovider.dart
test
lib
|models
|providers
|userproviderShould.dart
However, I'm having trouble figuring out if this approach is less than optimal for the Dart code. Each file in the test project seems to need to have a main
method, which feels odd. I'm also not clear on how to run the entire test suite. The Flutter test running (flutter test
) doesn't seem to understand directories. Running flutter test test/lib/providers
doesn't work while flutter test test/lib/providers/userproviderShould.dart
does. If it doesn't understand directories it certainly doesn't understand having to recurse into directories.
Is there a way to solve this that doesn't involve either having to build a fragile entry point that manually includes all the rest of the tests or writing a shell script to go run each file individually?