一尘不染

我无法在Dart插件中运行单个测试文件

flutter

我正在为Dart和Flutter开发一个插件,并且从一组测试开始,因为它是从Java实现中移植的。

我看到的问题是我可以运行所有测试,但不能运行单个测试文件或对其进行调试。

我使用了Android Studio项目生成器,并选择了“ Flutter Package”

我相信问题在于android studio无法将测试识别为抖动测试,并且未包含所需的导入。

测试代码如下所示;

import 'package:flutter_test/flutter_test.dart';

void main() {
  test('Test Name', () {
    ///Test cases in here
  });
}

我在尝试运行或调试单个测试时看到的错误是:

file:///E:/flutter/packages/flutter_test/lib/src/accessibility.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
       ^
file:///E:/flutter/packages/flutter_test/lib/src/binding.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
       ^
file:///E:/flutter/packages/flutter_test/lib/src/matchers.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
       ^
file:///E:/flutter/packages/flutter_test/lib/src/matchers.dart:9:8: Error: Not found: 'dart:ui'
import 'dart:ui';
       ^
file:///E:/flutter/packages/flutter_test/lib/src/test_pointer.dart:12:1: Error: Not found: 'dart:ui'
export 'dart:ui' show Offset;
^
file:///E:/flutter/packages/flutter/lib/src/rendering/binding.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show window;
       ^
file:///E:/flutter/packages/flutter/lib/src/rendering/box.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show lerpDouble;
       ^
file:///E:/flutter/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
       ^
file:///E:/flutter/packages/flutter/lib/src/rendering/editable.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show TextBox, lerpDouble;
       ^
file:///E:/flutter/packages/flutter/lib/src/rendering/error.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextStyle;
       ^

Process finished with exit code 254

我在这里还缺少其他配置步骤,还是在这里package:flutter_test/flutter_test.dart应该使用的替代方法?

我试图用纯飞镖换掉颤振测试,但是随后甚至没有测试可以加载。错误是;

Failed to load test harness. Are you missing a dependency on flutter_test?


阅读 365

收藏
2020-08-13

共1个答案

一尘不染

好的,所以我实际上找到了解决方案。

在Android Studio的“运行”下拉列表中,选择“ 编辑配置”,
然后按 + 按钮并选择“ Flutter测试
”。确保“测试”范围为“ 全部在文件中”, 并将其指向您的测试文件。
现在,您可以运行单个测试文件,也可以通过在运行下拉菜单中选择此配置,在android studio中对其进行调试。

2020-08-13