Flutter试验:跑|调试|配置文件按钮运行Gradle任务,但不运行单元测试

jvidinwx  于 2023-02-16  发布在  Flutter
关注(0)|答案(1)|浏览(152)

我正在为flutter应用程序编写单元测试,但无法使用测试文件的main()函数上方的Run | Debug | Profile按钮运行单元测试。
我有如下测试文件:

void main() {
  late HttpServiceBase httpServicBase;

  setUpAll(() {
    httpServicBase = HttpServiceBase();
  });

  group("get", () {
    test("given empty url, should throw exception", () {
        // some test code
    });
  });
}

我可以看到main函数上方的Run | Debug | Profile按钮。
但是,当我单击Debug按钮时,出现以下错误

Build file 'D:\FlutterApp\android\app\build.gradle' line: 90

* What went wrong:
A problem occurred evaluating project ':app'.
> Parameter specified as non-null is null: method com.android.build.gradle.internal.dsl.BaseFlavor.resValue, parameter value

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Exception: Gradle task assembleDebug failed with exit code 1

但是,当我运行flutter test .\tests\unit_tests\libs\services\http_service_test.dart时,测试按预期运行。
我没有具体的设置,所以我不知道可能出了什么问题。
谢谢

46qrfjad

46qrfjad1#

将文件夹从tests重命名为test即可解决此问题。

相关问题