颤动测试应该保存在哪里

Where should tests for flutter be kept

它们必须在根测试文件夹中吗?在使用 React 时,我更喜欢将测试放在组件附近,我可以用 Flutter 做到这一点吗?如果不是,建议将所有测试存储在一个测试文件夹中还是复制 lib 的结构?

这取决于不同类型的测试(unitwidgetintegration),但需要位于特定文件夹中。

来自 Flutters CookBook Guides

In general, test files should reside inside a test folder located at the root of your Flutter application or package.

单元和小部件测试必须位于 test 文件夹中。 集成测试必须放在名为 test_driver 的单独目录中。这两个文件夹必须与您的 lib 文件夹位于同一级别。