我正在为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
时,测试按预期运行。
我没有具体的设置,所以我不知道可能出了什么问题。
谢谢
1条答案
按热度按时间46qrfjad1#
将文件夹从
tests
重命名为test
即可解决此问题。