在flutter测试中获取测试文件的名称

时间:2019-11-27 17:34:17

标签: flutter

假设我有一个抖动测试文件foo_test.dart,其中:

void main() {
 final file = ...how to get the path of this file... 'foo_test.dart';
 ...
}

我该如何实现?

1 个答案:

答案 0 :(得分:0)

以下代码段允许检索包含main()的文件:

final mainFile = Uri.parse(RegExp(r'#.*main \((.*):.*:.*\)')
        .firstMatch(StackTrace.current.toString())
        .group(1))
    .toFilePath();
相关问题